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? E.g. 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>``
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top