<Leader> quite often in other people's vimrc files.
Like this one.
What is it? What does it do?
Vim is full of various commands, which are assigned to almost all keys on the keyboard. But this causes a problem: Which commands can we use for our own commands, without interfering with existing ones? And at this moment, the
<Leader> key comes into play. Think about
<Leader>-key like a namespace for any user-defined commands. You can assign any command to a mapping with a leading
<Leader> and you can be fully confident that your mapping won't break anything.
Default key for
<Leader> is backslash.
To define a mapping which uses the "mapleader" variable, the special string "
<Leader>" can be used. It is replaced with the string value of "mapleader". If "mapleader" is not set or empty, a backslash is used instead. Example:
:map <Leader>A oanother line<Esc>
:map \A oanother line<Esc>
:let mapleader = ","
It works like:
:map ,A oanother line<Esc>
In other words, it lets the first key of mappings (specified in terms of
<Leader>) be user defined.