inoremap jk <esc>
And
inoremap kj <esc>
In your vimrc file should do it.
inoremap jk <esc>
And
inoremap kj <esc>
In your vimrc file should do it.
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.
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- 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.
> 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.
What if you want to type an abbreviation and expand it when you escape from insert mode to normal mode?
I press space or tab or enter or actual escape if I need an abbreviation and it happens to be at the end of what I intended to insert... I pretty much never rely on escape to do the abbreviations though because it's not at the end of what I want to insert anyway.
I also don't use visual mode enough to need to have an escape for it. you can certainly change the timeout on visual mode and add a visual mode mapping for that too if you want to do that. It seems you have a the attitude of this is the only "correct" way to do it. I don't really care if you use it or not... I was merely providing an alternative way to do what you want with the added benefit of it giving you an extra modifier key that you can bind other things to. You can also map it globally or for each of the handful of modes you want to escape from using it.
I also bind ALT-J and ALT-K globally to down and up arrows which is super useful when any kind of drop downs turn up and you want to select different options
I also don't use VIM the program that often, more often than not I'm using Vim bindings in other editors. Though they all have their quirks in terms of what they support.