4 ms·
The first thing I do on a new system is map my Caps Lock key to Escape[1][2][3] so that I can use Vim conveniently without having to reach the physical Escape k
by foo101 9y ago
The first thing I do on a new system is map my Caps Lock key to Escape[1][2][3] so that I can use Vim conveniently without having to reach the physical Escape key placed awkwardly at the corner of the keyboard.
The choice of Escape key to return to normal mode and H, J, K, L for navigation makes total sense if we look at the original Lear Siegler ADM-3A terminal[4] that Bill Joy used while creating vi, but in the modern day keyboard, the choice of Escape key to return to normal mode really disturbs the otherwise fine ergonomics of using Vim.
[1]: https://github.com/susam/uncap#uncap https://github.com/susam/uncap#uncap
[2]: http://vim.wikia.com/wiki/Map_caps_lock_to_escape_in_Windows#Utilities http://vim.wikia.com/wiki/Map_caps_lock_to_escape_in_Windows...
[3]: http://vim.wikia.com/wiki/Map_caps_lock_to_escape_in_XWindows#Comment_from_tip_327_.28now_removed.29 http://vim.wikia.com/wiki/Map_caps_lock_to_escape_in_XWindow...
[4]: https://vintagecomputer.ca/wp-content/uploads/2015/01/LSI-ADM3A-full-keyboard.jpg https://vintagecomputer.ca/wp-content/uploads/2015/01/LSI-AD...
- kdoherty 9y agoI had a really hard time getting into Vim until I found out everyone I knew who was using it had mapped something else to escape. Once I did the same, it was much easier to get started.
- protomikron 9y agoFor me it was the same. Using ESC is really ergonomically awkward for me. There are also people using Ctrl-C (which works by default) - but I prefer the 'jj' or similar method. It's also useful to use Bash in vim-mode and also remap the esc-key, e.g. set editing-mode vi set keymap vi $if mode=vi set keymap vi-insert "jj": vi-movement-mode $endif Something like this - you can then search Bash history via '/', etc.
- weaksauce 9y agoMapping jk and kj to escape and mapping caps lock to some other hyper key is way better than caps lock to esc IMO. You can just mash both j and k together and you are out of it. inoremap jk <esc> And inoremap kj <esc> In your vimrc file should do it.
- foo101 9y agoI have considered such alternatives in the past and they did not work for me. For example, how can I conveniently type the string "jk" or "kj" with such a configuration? The artificial delay I have to introduce between typing "j" and "k" to actually type "jk" is unacceptable. Although it is rare, I sometimes do have to type "jk" in special circumstances such as while typing LaTeX code. Mapping Caps Lock to Escape is just a much cleaner solution that does not come with any surprises.
- humblebee 9y agoI use the 'jk' and 'kj' mapping for escape as well, though I've never actually needed to type those characters out myself or at least it's so rare I don't remember. However, everyone is different. What I'd suggest if you want to give it a try is to also set the `timeoutlen` to a lower value. By default it's usually 1000ms, but that can be dropped quite a bit I believe without much interference. autocmd InsertEnter * set timeoutlen=100 autocmd InsertLeave * set timeoutlen=1000
- foo101 9y agoThis 'jk' and 'kj' mapping works only to get out of the Insert mode. But it does not match the full capability of the original 'Escape'. - How do you escape from visual mode to normal mode? - How do you ensure that your abbreviation gets expanded when you escape from insert mode to normal mode? - How do you escape from operator-pending mode to normal mode? With this mapping, if you press 'd' to delete something and then change your mind and decide to return to normal mode, you are forced to use the original 'Escape' anyway. If you happen to press 'jk' due to habit at this time, it is going to end up deleting lines. For these reasons, I thought to have a clean mapping of another convenient key (such as Caps Lock) to Escape at an operating system level, rather than trying to make Vim treat some other key as Escape in certain modes.
- protomikron 9y agoAnother approach is using 'jj'. > The artificial delay I have to introduce between typing "j" and "k" to actually type "jk" is unacceptable. I tried the CAPS approach and tried using it via my left pinky, but find it too awkward to use - but this is probably a very individual thing and it's good that Vim supports it via its remapping capabilities. But I hear you, sometimes if I have to type the string "jj" I get really confused, but this happens not very often.
- sanbor 9y agoYou can use Ctrl-C as an ESC shortcut in vim.