1

I'm using nVim v0.4.3 and I'm having trouble getting multiline inserts to work in visual blockwise mode.

You can check this asciinema to see what I'm doing.

https://asciinema.org/a/sgoQGZlIwkAM1QkKSZptIc5d9

As you'll see there, the sequence I'm using is <S-v>jjj<S-i>test <ESC> and what I end up with is the first line is modified but not the rest. am I missing something?

  • 1
    Did you type <S-v> (like in your question) or <C-v>? <S-v> starts line-wise visual selection, not block-wise, which is <C-v>. – Martin Tournoij Apr 30 '20 at 2:45
  • @MartinTournoij good eye! That did the trick. Is there a way to get the same behaviour w/ line-wise instead of block-wise? Also feel free to post that as the answer I'll accept it :thumbsup: – vvMINOvv Apr 30 '20 at 3:53
  • 2
    Not as far as I know. How would Vim know where to insert the text? With block-wise mode you select column 10, but with line-wise the entire line is selected. You can use :s/^/.../ and :s/$/../ in line-wise to insert text at the start and end of the lines though. – Martin Tournoij Apr 30 '20 at 3:59
  • You can always use blockwise to insert where you'd think you need linewise... For the start of the line, just use blockwise on the first column. To append at the end of lines, use $ and A, it will append to the end of the lines (even though they don't really align, as blockwise normally does.) – filbranden Apr 30 '20 at 4:49
  • duplicate of vi.stackexchange.com/a/24752/71 – Christian Brabandt Apr 30 '20 at 6:14
1

TL;DR use <C-v> instead of V

The cause in that you use S-v instead of <C-v>(V) before S-i(I)

Block insert works only for Vertical blocks, not for selected lines.

Difference between V and C-v

  • V (<S-v>) is for selecting whole line$
  • <C-v> starts selecting Visual block:

    With CTRL-V (blockwise Visual mode) the highlighted text will be a rectanglebetween start position and the cursor.

I in insert vs visual modes

In insert mode I just inserts text before the cursor:

I Insert text before the first non-blank in the line [count] times.

To insert before every selected lines use Visual block mode: See I block insert v_b_I:

Visual-block Insert (v_b_I)

With a blockwise selection, I{string} will insert {string} at the startof block on every line of the block, provided that the line extends into theblock. Thus lines that are short will remain unmodified. TABs are split toretain visual columns.See v_b_I_example.

Not the answer you're looking for? Browse other questions tagged or ask your own question.