Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

So far I've been trying to use Vim in as vanilla a configuration as possible, so as to save myself hassle when moving between machines. However, there are a few things I'd really like to bind keys, such as to shorten "_diwP which I use often to delete the word under the cursor and replace it with one from the clipboard. Are there any particular keys that are conventionally reserved for user-defined mappings? The point of this question is mostly that I would like to avoid hassle later on when I decide to install some plugin or take my configuration files to vim on another OS and find that my key mappings clash with something else.

share|improve this question
add comment

3 Answers

up vote 8 down vote accepted

All the letters are already taken:

http://www.dc.turkuamk.fi/docs/soft/vim/vim_idx.html#vim_idx.html (broken link) http://web.archive.org/web/20091026182612/http://www.dc.turkuamk.fi/docs/soft/vim/vim_idx.html (web archive - HTML) http://www.rpi.edu/dept/acm/packages/vim/4.2/sgi_62/lib/vim/vim_idx.txt (plaintext)

But if I want permenant commands I use <leader> as a prefix.

:map <leader>l    :list!

The default leader is '\' so by typing \l I can switch the state of list.
Note the leader can be changed. See :help leader

Note: to make sure I have my vim mapping available anytime I want them, I just put the .vimrc file on a convenient webserver. Then I can just use wget (or a browser) to get my .vimrc file at any time.

share|improve this answer
add comment

All keys are safe to remap in Vim. However, there are two types of mappings: recursive and non recursive.

a) Recursive:

If you remap for example,

nmap x dd

x deletes the line instead of one character

you will have effectively lost the x key for future mappings, as well as overwritten the delete character function. Were sometime in the future some plugin depend on that key, that could present a problem.

For example,

nmap <C-x> xxx

will delete three lines instead of three characters, because it is effectively doing dddddd. This is a problem since effectively were some of your plugins to use the x (and they surely will) it will create problems (nasty ones).

b) Non recursive mapping

nnoremap x dd

solves that problem in a way that it will assign dd to x so that upon your pressing x you delete a line instead of a character, but any future mapping

nnoremap <C-x> xxx

will have the original x on the right hand side functionality.

Always use nnoremap, inoremap ... the non-recursive mapping instead of nmap, imap and so on ... unless you have a very strong reason for doing the opposite.

share|improve this answer
add comment

I have a french keyboard. I use é, è, à, ù, µ, §, £, ç ...

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.