3

When I do a visual block insert with virtualedit=all I want to insert into all selected lines regardless of what text is already in those lines. Instead the behavior I get is that the line where I begin the visual block is always inserted into and the other highlighted lines are inserted into only if they already contain text in the selected column or the immediately preceding column.

For example, with _ as the cursor, and the following text that contains no trailing spaces (the cursor is outside the text):

abc  _
abcd
abcde
ab

if I begin a visual block where the cursor is and continue down to the last column, then block insert foo, and then press escape I end up with this:

abc _foo
abcd
abcdefoo
ab

Instead, I want this:

abc _foo
abcd foo
abcdefoo
ab   foo
4

This is due to the behaviour of blockwise operators. In this particular example, you need to append the text. That is, with the visual block selection, here marked with _,

abc  _
abcd _
abcde_
ab   _

you can type Afoo<esc> to get the desired output, i.e.

abc _foo
abcd foo
abcdefoo
ab   foo

With visual block insert, see :h v_b_I, you will only insert text if the line extends into the block. However, with visual block append, see :h v_b_A, you will append to every line, even if the lines do not extend into the block. In the latter case, whitespace will be added as expected.

For more information, see :h blockwise-operators.

  • I realise that i should explain why. However, i did not have the time to find out. I will update if and when i find out :-) – Karl Yngve Lervåg Jan 8 '16 at 23:07
  • This asymmetry between insert and append does seem really quirky. If there's a reason I should expect this that would be useful to know. Thanks! – Praxeolitic Jan 9 '16 at 2:41
  • That's how it is. See :h blockwise-operators (v_b_I, v_b_A follows). – VanLaser Jan 9 '16 at 15:32
  • The reason for that is explained in the help – Christian Brabandt Jan 9 '16 at 16:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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