They say anything you can do from the center of the keyboard is fastest and most efficient. I think Esc is pretty damn far for my pinky to stretch. What should I do?
There are several options: You can alternatively press Ctrl + [, which is equivalent to Esc. You can define a mapping, e.g. jj, or jk and kj. Or you remap another convenient key (Caps Lock, Ctrl), to Esc. You'll find a lenghty discussion at Avoid the escape key on the Vim Tips Wiki.
I recommend mapping the conveniently located, but seldomly used Caps Lock to Esc. It is described in Map caps lock to escape in Windows and Map caps lock to escape in XWindows.
So the English language has very few occurrences of two j's in a row. In fact here's all of them: hajj, hajjes, hajji, hajjis. Seems to be really common for guys named Hajj or people who've done a pilgrimage to Mecca. But for those of us with no friends name Hajj, or trips to Mecca jj makes for a really great shortcut for Esc in vim.
I especially love this remap because it saves me those times when I don't realize I'm in insert mode : ( j'ing around like I'm trying to scroll, meanwhile there's a nice string of j's accumulating inside a function somewhere. The worst is when someone leaves your capslock on. Then you have no idea why your code is erupting!
I've also remapped kk to Esc, but the cost is a bit higher. Again here are English words with double k's (lots more than double j's):
bookkeeper bookkeepers bookkeeping bookkeepings chukka chukkar chukkars chukkas chukker chukkers dekko dekkos hokku jackknife jackknifed jackknifes jackknifing jackknives knickknack knickknacks lockkeeper lockkeepers markka markkaa markkas pukka quokka quokkas shikker shikkers stockkeeper stockkeepers sukkah sukkahs sukkot sukkoth trekked trekker trekkers trekking yakked yakker yakkers yakking yukked yukking zikkurat zikkurats
And lastly, here's the code to for those remappings (just drop those two lines in your .vimrc file in your home directly, should work as long as there are no conflicts, you may need to create this file if you haven't already.):
inoremap jj <Esc>
inoremap kk <Esc>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With