what are safe key combinations to remap in vim

185 views
Skip to first unread message

Rahul

unread,
Apr 9, 2008, 12:40:26 PM4/9/08
to vim_use
Whenever I want to assign a repetitive operation to an easier
keystroke I'm always hesitant of inadvertently overwriting some great
inbuilt key combination. ( bad idea to remap dd or yy or 'a for
instance!)

Is there a suggestion of "safe" key combinations to go for? I use a
vt100 terminal so have only access to Fn1-Fn4 (or not?) and have used
up those already! :(

-Rahul

Yegappan Lakshmanan

unread,
Apr 9, 2008, 12:52:28 PM4/9/08
to vim...@googlegroups.com
Hi,

You can refer to the "Finding unused keys" section in the "Mapping keys
in Vim" tutorial available at:

http://vim.wikia.com/wiki/Mapping_keys_in_Vim_-_Tutorial_%28Part_2%29

- Yegappan

Benjamin Fritz

unread,
Apr 9, 2008, 12:54:36 PM4/9/08
to vim...@googlegroups.com

Meta keys are almost always safe (<M-A>, <M-B>, etc.). Check for
mappings from plugins, etc. before using.

When in doubt, use the help. For example, to see if CTRL-J is taken
(it is, but there are several commands to do the same thing) type
:help CTRL-J and then press CTRL-D instead of ENTER to list all
results. Then view each result to see what they do and if there are
any alternate ways to do the same thing before mapping.

If the mapping is for one mode only, you can prepend the mode. For
example, for CTRL-J in insert mode,

:help i_CTRL-J

Benjamin Fritz

unread,
Apr 9, 2008, 12:59:30 PM4/9/08
to vim...@googlegroups.com

Oh, and you can also use the map leader (see :help <Leader>), which
defaults to the backslash key. For example,

nmap <leader>h :echo "hello world!"<CR>

Gene Kwiecinski

unread,
Apr 9, 2008, 1:54:06 PM4/9/08
to vim...@googlegroups.com
>Is there a suggestion of "safe" key combinations to go for? I use a
>vt100 terminal so have only access to Fn1-Fn4 (or not?) and have used
>up those already! :(

Lotta people use ';' and/or ',' as a leader char. So if you want to
/r/eformat some text, you can map ",r" to a set of commands, function,
etc. Kinda the way 'g' prefaces like a brazillion separate commands
(go-to, reformat, etc.).

I've been thinking of doing that for the first time, as I never had
occasion/need before to remap anything like that. Really should, but
never got a round tuit.

Benjamin Fritz

unread,
Apr 9, 2008, 2:05:10 PM4/9/08
to vim...@googlegroups.com

The problem with ; and , is that they are already commands, used to
repeat the last f, t, F, or T search to more rapidly jump to a certain
character.

See :help ; and :help ,

Reply all
Reply to author
Forward
0 new messages