How can I make a visual mapping's behaviour dependent on the number of lines selected?
I tried creating an expr map, but the visual start and end marks don't seem to be correct:
function! Xsurround() abort let is_linewise = mode() ==# 'V' let line_count = line("'>") - line("'<") + 1 let g:global_count = line_count if is_linewise && line_count == 1 return "\<Esc>\<Plug>Yssurround" else return "\<Plug>VSurround" endif endf xmap <expr> s Xsurround()
vipsb on that block of code and
g:global_count is 1. (The current line is surrounded.)
I'm trying to make an xmap for surround so a single selected line gets surrounds at beginning and end of the line instead of on the line before and after (there's already an option to always do the line before and after --