I have previously used the following vim mapping so that when I press esc
, vim does not 'creep backwards':
:inoremap <silent> <Esc> <Esc>`^
However, this has quite unexpected side-effects (to me, at least), for example, now that I have an <Esc>
on the lhs, the arrow keys won't work anymore in insert mode (and a few other items that send escape sequences to vim.
Is there a better way to do this, or perhaps a settings within vim that alters this behavior? Ultimately, I want the behavior or <Esc>`^
, I just don't want to have an <esc>
that is mapped on the lhs for other reasons. What would be the best approach here?
No need to remap <ESC>
. You could try using this autocmd
in your .vimrc
:
au InsertLeave * call cursor(getcurpos()[1], getcurpos()[2]+1)
This code is a reimplementation of the approach described in the Vim wiki , which is more verbose (and possibly outdated). The command has a small latency though.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.