As you have probably realized, keyboard real estate in Vim is pretty heavily occupied in normal mode. Specifically, just about every key is already bound to a command. Luckily, Vim provides a facility to define additional mappings on these keys. It's called a mapleader, and it's easy to setup.
First you need to define what key you want your mapleader to be. I prefer comma because it's (in my daily usage) unused, and it's easy to reach. Add the following to your vimrc.
let mapleader = ","
Now that mapleader is defined, you can use it for custom mappings at will.
:map <leader>n :new<cr>
Press `,' then `n' in normal mode, and it splits to a new window.
:map <leader>i I
Press `,' then `i' in normal mode, and it puts you into insert mode on the first character of the current line.
These usage examples are slightly obtuse, so I'll be showing how to incorporate using a mapleader into tab management in an upcoming post.
Showing posts with label mapleader. Show all posts
Showing posts with label mapleader. Show all posts
Friday, November 21, 2008
Subscribe to:
Posts (Atom)