I want to have different behavior for the different visual modes. As an example if I wanted to vnoremap S{
so that it has the following behavior:
- surrounds the selection in
v mode
, (puts{
at the start of selection and and}
at the end of selection) - surrounds the lines in
V mode
, (puts{
above and}
below the selected lines) - surrounds the block in
ctrl-v mode
, (puts{
s on the left edge and and}
s on the right edge)
what would that look like? I have this but its buggy (behavior isn't consistent, seems to toggle behavior on every attempt.
vnoremap <expr> S{ visualmode() ==# "v" ?
\ "<Esc>`>a}<Esc>`<i{<Esc>" : visualmode() ==# "V" ?
\ "<Esc>`>o}<Esc>`<O{<Esc>va{=" :
\ "A}<Esc>gvI{<Esc>"