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.
How do you get which side of the visual mode selection the cursor is on in vimscript?
vimscript;cut copy paste;visual mode
Not 100% sure if this is what you're trying to do, but following command will restore the cursor to the position it was in during the last visual mode:execute normal! gv\<Esc>This may or may not be what you want, depending on what actions you're applying to the text selected in visual mode. (It works well if you're just yanking the text.)If you need to know the cursor position before doing anything with the selection, you could try using :execute normal! \<esc>, grabbing the cursor position, and then using :normal! gv to reset the visual selection. 