Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VIM: Mappable (unused) shortcut letters?

Tags:

I'm trying to create two mappings which are efficient for myself:

map X ddp 

Which I'd use to delete and paste in one go.

map X "_dw 

Which would delete a word without yanking into a register.

However I don't want to break any existing, useful shortcuts so I'm wondering what keys I could use - any suggestions? Am I being too uptidy?

like image 207
meder omuraliev Avatar asked Dec 11 '09 17:12

meder omuraliev


People also ask

What is the silent key in Vim?

Silent. Adding <silent> prevents stdout in Vim when a command runs. Sometimes when you execute a command call in Vim, it gets echoed.

How do I map a key in Vim?

To map keys that work only in the insert and replace modes, use the 'imap' or 'inoremap' command. To remove a keymap from insert mode, use the ':iunmap' command. For example, the following command removes the insert mode map for <F2>.

What is Ctrl in Vim?

You can put your cursor on the word and CTRL-] will jump to the function definition. To get this functionality you need some external program to generate a tags file on the code so that vim can know where the definitions are. It's also used to jump to help file locations.


1 Answers

vim help has a section :he map-which-keys

1.7 WHAT KEYS TO MAP                                    *map-which-keys*  If you are going to map something, you will need to choose which key(s) to use for the {lhs}.  You will have to avoid keys that are used for Vim commands, otherwise you would not be able to use those commands anymore.  Here are a few suggestions: - Function keys <F2>, <F3>, etc..  Also the shifted function keys <S-F1>,   <S-F2>, etc.  Note that <F1> is already used for the help command. - Meta-keys (with the ALT key pressed). |:map-alt-keys| - Use the '_' or ',' character and then any other character.  The "_" and ","   commands do exist in Vim (see |_| and |,|), but you probably never use them. - Use a key that is a synonym for another command.  For example: CTRL-P and   CTRL-N.  Use an extra character to allow more mappings.  See the file "index" for keys that are not used and thus can be mapped without losing any builtin function.  You can also use ":help {key}^D" to find out if a key is used for some command.  ({key} is the specific key you want to find out about, ^D is CTRL-D). 
like image 96
michael Avatar answered Oct 11 '22 23:10

michael