Is there a way to bind
A in visual mode and visual line mode to switch the selected region to a visual block selection with the same boundaries?
I'd like to be able to use visual line mode to select a group of lines and then use
A to add text before or after all of the lines.
For instance, in the following file (with line numbers)
1 a 2 b 3 c 4 d 5 e 6 f 7 g 8 h
<esc> gg V G I # <space> <esc> produces
1 # a 2 b 3 c 4 d 5 e 6 f 7 g 8 h
and I'd like it to produce this, just as visual block would.
1 # a 2 # b 3 # c 4 # d 5 # e 6 # f 7 # g 8 # h
I've tried using the following keybinding to switch to visual block mode right before inserting in every mode except visual block, but it loses the selection region.
vnoremap <expr> I mode()=~?'\cv' ? 'I' : '<c-v>I' vnoremap <expr> A mode()=~?'\cv' ? 'A' : '<c-v>A'
"\<C-v>"is the string that mode
'\cv'as described here (vi.stackexchange.com/a/6118/6420), evidently. Plugin: github.com/kana/vim-niceblock/blob/master/autoload/…