I'm writing some vimscript and would like to preserve the cursor position after a yank occurs in visual mode.
Ths issue is that I can't find any way to get the cursor position while in visual mode. It's always at the beginning or the end of the selection but it's not clear which one.
There are the >
and <
marks to get the beginning/end of the selection. There is also v
which appears to work nearly identical to <
. And of course there is .
for cursor position but when in visual mode this returns the beginning of the selection instead.
getpos()
. Could you show us what you already have?