After using and learning Neovim for over 2 years, I have finally published my first plugin – better-escape.vim.
Better-escape.vim is a plugin to help users escape from insert mode quickly without experiencing the lagging that comes with Vim mappings.
inoremap jk <ESC> inoremap jj <ESC> inoremap kj <ESC>
However, this comes with an annoyance. If you use
jk to escape insert mode,
whenever you press
j in insert mode, Vim will not write it to the buffer, it
will wait for
milliseconds to see whether you want to use the
jk mapping or you want to
j literally. This issue is easily noticeable when we have a relatively large
In my previous post, I
have already talked about this topic and provided a solution. The solution is to
use an insert mode mapping for
k only. When we press
k, we check if the previous
j. If that is true, we will erase previous
j and go to normal mode.
k is inserted as is. There is no lagging any more. The problem is that
now we can not input
jk directly in insert mode. To insert
k when the previous
j, we need to press
Ctrl-V, then press
In better-escape.vim, I have a smarter solution. We will check the time spent
k in insert mode. If the time is above a predefined
jk will be inserted literally. Otherwise, we will escape from
insert mode. With this plugin, you can easily customize the shortcut for
escaping insert mode, as well as the time threshold used.
License CC BY-NC-ND 4.0