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.
The default <leader> key is a backslash \ . To change the leader key to the comma , add let mapleader = “,” to your vimrc (to use the space key add let mapleader = “ “). Reload vim and test your new <leader> key. The leader key can be whatever key you choose.
Opening vimrc Using file name completion, you could type :e $M then press Tab until you see the desired variable. If you only want to see the path, type :echo $M then press Tab to see the variable, and press Enter. In gvim, the Edit menu includes "Startup Settings" which will use $MYVIMRC to edit your vimrc file.
The global or system-wide vim configuration file is generally located under the /etc/vim/vimrc . This configuration file is applied to all users and when Vim is started this configuration file is read and Vim is configured according to this file contents.
<silent> tells vim to show no message when this key sequence is used. <leader> means the key sequence starts with the character assigned to variable mapleader -- a backslash, if no let mapleader = statement has executed yet at the point nmap executes.
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.
Be aware that when you do press your <leader>
key you have only 1000ms (by default) to enter the command following it.
This is exacerbated because there is no visual feedback (by default) that you have pressed your <leader>
key and vim is awaiting the command; and so there is also no visual way to know when this time out has happened.
If you add set showcmd
to your vimrc
then you will see your <leader>
key appear in the bottom right hand corner of vim (to the left of the cursor location) and perhaps more importantly you will see it disappear when the time out happens.
The length of the timeout can also be set in your vimrc
, see :help timeoutlen
for more information.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With