I have this mapping that allows me to move to the middle of the line:
nnoremap <silent> M :execute 'normal! ' . (virtcol('$')/2) . '\|'<CR>
Can it be extended to work in visual mode?
This seems to work.
vnoremap <silent> M :<c-u>execute 'normal! gv' . (virtcol('$')/2) . '\|'<CR>
Since typing an ex command exits visual mode you need to first reselect the visual mode before executing the |
command.
<c-u>
clears the command line which was prepopulated with '<,'>
gv
reselects the old virtual selection.
vnoremap was used so that its a visual mode mapping.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With