How and why?¶
Vim is my editor of choice. I recently mapped the sequence “jk” to exit Insert mode. I briefly mentioned it in my 2017 year end summary post. In this blogpost I am going to describe how and why I did it.
Read this vim.wikia.com post to get an overview of the different options.
To hit the Escape key makes sense for me when I am at the end of one thought or editing part — I hit escape to get to Normal mode, think about what I have to do next and move on. But when I am right into an editing frenzy the reach to the Escape key slows me down and I don’t want to be slowed down when thinking and editing align at a fast pace. An additional reason is that the Escape key on my Libreboot T400 laptop is not that easy to reach with my pinky.
My CapsLock key is already remapped system-wide to an additional Ctrl key. I went for the “jk” solution because it is easy to type — it feels more natural than “jj” for me. There is a noticeable visual cue when typing “j” but it doesn’t bother me.
Add a line to config¶
Simply add the following line to your
inoremap jk <Esc>
Wait, what if I have to type “jk”?¶
It is still possible but you have to wait for the timeout after typing “j” and then type “k”. This post excluded I rarely type “jk” so I don’t care about the delay while waiting for the timeout. (Disclaimer: This post was painful to write. I left Insert mode most of the times when I tried to insert “jk” literally)
Below is a quick gif of the remapped key sequence in action. First I press Space several times and insert “jk” — notice the delay while waiting for the timeout (cursor stays on the j-character and does not move on for a while). Then I stay in Insert Mode and add some new lines, type “tmp” and exit Insert mode by pressing “jk”. If you take a close look you will see a “j” appear and disappear after I have typed “tmp”. As the last step in the gif I move one line down by pressing “j” in Normal mode:
(Click on the gif for a fullscreen view)
If you have any questions, suggestions, thoughts and comments please feel free to email me.
License of this blog post:
This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.