tags:

views:

874

answers:

3

I see <leader> in many .vimrc files, and I am wondering what the meaning of it is? What is it used for? Just a general overview of the purpose and usage.

Thanks!

+5  A: 

The "Leader key" is a way of extending the power of VIM's shortcuts by using sequences of keys to perform a command. The default leader key is backslash. Therefore, if you have a map of <Leader>Q, you can perform that action by typing \Q.

Mikeage
Thanks for the help, brain wasn't working today.
Bob Martens
thanks @Manni for the edit. Forgot about this autoformatting stuff...
Mikeage
A: 

In my system its the \ key. it's used for commands so that you can combine it with other chars.

Arkaitz Jimenez
I'll have to check my configs, I probably left it at that.
Bob Martens
+8  A: 

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.


Vereb
+1 the change to `,` is a good one. Much easier to reach than `\\`, and who users `,` in vim anyway?
Gabe Moothart
Thanks for the help, this definitely points me in the right direction.
Bob Martens
@Gabe Moothart. :h , gives you "Repeat latest f, t, F or T in opposite direction [count] times."It is quite convenient.
Maxim Kim