What is the <leader> in a .vimrc file?

Bob Martens picture Bob Martens · Nov 19, 2009 · Viewed 371.4k times · Source

I see <leader> in many .vimrc files, and I am wondering what does it mean?

What is it used for?

Just a general overview of the purpose and usage would be great.

Answer

Vereb picture Vereb · Nov 19, 2009

The <Leader> key is mapped to \ by default. So if you have a map of <Leader>t, you can execute it by default with \+t. For more detail or re-assigning it using the mapleader variable, see

:help leader

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>
Works like:
    :map \A  oanother line <Esc>
But after:
    :let mapleader = ","
It works like:
    :map ,A  oanother line <Esc>

Note that the value of "mapleader" is used at the moment the mapping is
defined.  Changing "mapleader" after that has no effect for already defined
mappings.