views:

121

answers:

3

Besides F1, F2, F3, (Ctrl + Fs and so on), which are good (available) keys to create custom commands on Vim?

Some plugins use , and \. For instance, \be and ,cc. Which are other good available keys to create custom commands on Vim?

A: 

Since the ESC key is the most used key in vim it beneficial to have it mapped somewhere else.

I've seen others used Ctrl+[, jj, ;; and for a secondary ESC key

imap  jj  <ESC>
imap  ;;  <ESC>
Yada
+3  A: 

I'm a fan of using <Leader> in all my custom maps. That way I can easily avoid stomping on default mappings, and I can quickly change my mapleader whenever I want/need to.

Randy Morris
+1  A: 

Personally I have remapped my CAPSLOCK as CTRL

and for vim

imap jk <ESC>

The last trick has helped me a lot. I dont have to lift my fingers to get out from normal mode to insert mode.

And it works both ways, jk in normal mode is an innocent combination - move down one, move up one. So by remapping jk as ESC you're not losing out anything.

jeffjose
Seriously? How do you type stuff like `Dijkstra`?
Greg Hewgill
if by `Dijkstra` you mean `D(Delete)i(Insert)jk(Escape)s(substitute)tr(find r)a(append)` Yes. I dont have to lift my hand for escape key. Ever.
jeffjose
No, I meant the literal text `Dijkstra`, in insert mode. I tried your suggested `imap` command and `jk` actually exits insert mode as expected. So typing `Dijkstra` in insert mode ends up inserting `Dtra` because `jk` exits insert mode and `s` deletes the `i` and reenters insert mode.
Greg Hewgill
The answer is you do `Dij` wait for a sec and then type `kstra``jk` when typed together - and I mean fast - will get you out of insert mode. Typing them slowly gets what you want.
jeffjose