Quantcast
Channel: chooru::code » map
Viewing all articles
Browse latest Browse all 2

How to map key sequence to command in Vim

$
0
0

Vim and the thousands of plugins written for it come with commands that can be used to enable, disable, toggle or invoke an action. Typically, these commands are textual and verbose to type in. For example, the command to toggle the Gundo window is :GundoToggle

Vim is highly flexible, in that it gives you the freedom to map these commands to any key sequence you prefer. For example, I decide to I want to toggle Gundo by typing the Leader key, followed by gu. The leader key is mapped to the backslash (\) key.

To map this key sequence to the Gundo toggle command, add this line to your vimrc:

nnoremap <Leader>gu :GundoToggle<CR>

Note how the Vim mode for the mapping is specified (normal mode), how the Leader key is specified and how the carriage return has to be explicitly specified.

Any command can be mapped in this way to any key sequence you desire in Vim.

Tried with: Vim 7.3



Viewing all articles
Browse latest Browse all 2

Trending Articles