I see <Leader> quite often in other people's vimrc files.
Like this one.
What is it? What does it do?
I see <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 quote :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>
In other words, it lets the first key of mappings (specified in terms of <Leader>) be user defined.
<Leader> is that it provides you with a "clean" way to provide custom shortcuts, without overriding existing Vim shortcuts.
– Martin Tournoij
Feb 16 '15 at 13:00
<leader>, this one wants to know what<leader>means. So that that value can be interpreted. It is the difference between asking "In newton motion what is v?" and "Given an apple falled from a 10m high tree, what is v when it hits the ground?' – Frames Catherine White Feb 16 '15 at 04:26<Leader>and<leader>, right? – Nikos Alexandris May 03 '15 at 11:31