lundi 25 avril 2016

Now I use space as leader

Lately, I read an increasing number of articles about using space bar as leader key to Vim. So I decided to give it a try.

Leader key is a key that can be use in your Vim mapping with the <leader> keyword. For instance:

" Typing <leader> then n in normal mode toggles NERDTree
nnoremap <leader>n :NERDTreeToggle<cr>

So it can quickly become a mapping trigger.

I have to admit I am a recent user of the leader key. By default, it's set to backslash. You can change it by writing the line bellow in your .vimrc:

let mapleader='<some_char>'

Backslash is not convenient, even less for French users sticking with French keyboard layout. So I changed to the comma (as I read it was the way to do). It makes me begin to use it in my mapping. But I have not using it a lot so far, as the comma does not get so easily under my finger.

And a couple of days ago, I decided to map it to space. And I got my mind blown!

" doing so is enough
let mapleader=' '

Obviously, the space bar is the most accessible key of your keyboard, so mapping can be typed as easily as possible.

The greatest effect is that it makes me think about creating new mappings to improve my productivity. And I have a lot of fun doing it since then. I shall update my .vimrc on github soon. I have put some other new stuff in it.