vim Key Mappings in Vim Map leader key combination

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Extensions
> Step 2: And Like the video. BONUS: You can also share it!

Example

The leader key could be used as a way to create a mapping with a key-binding that can be overridden by the end user.

The leader is the \ key by default. In order to override it, the end-user would have to execute :let g:mapleader='somekey(s)' before defining the mapping.

In a typical scenario, the mapleader is set in the .vimrc, and plugins use <Leader> in the keybinding part of their mappings to have them customizable.

In the plugin, we would define mappings with:

:nnoremap <Leader>a somecomplexaction

This would map the somecomplexaction action to the \+a key combination.

The a action without the leader does not change.

It's also possible to use <Plug>Mappings to leave more room to customise plugins keybindings.



Got any vim Question?