简体   繁体   中英

vim: restore cursor to original position after <esc> from visual mode

When I'm in the visual mode and I decide to switch back to normal by pressing <esc> then I'd like to have the cursor back on the position where I entered the visual mode. How can it be achieved? Eg something like:

vnoremap <esc> <esc>`<

but this will return always only to the beginning of the visual block.

Use mark. help mark

nnoremap v m`v
nnoremap V m`V
nnoremap <C-v> m`<C-v>
vnoremap <esc> <esc>``

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM