I'm trying to understand how the visual-block mode deals with Backspace and Delete, and if it is possible to vertically select a column of text, delete some characters, then insert new ones in a single selection.

For example, with these 3 lines of code (each proceeded with 2 spaces):

  a = 1;  
  b = 2;  
  c = 3;  

With my cursor on a I press Ctrlvjj selecting all the letters, then I to go into insert mode. At this point I can delete the two preceeding spaces with Backspace then start typing var but when I hit Esc I get the following:

var a = 1;
  r b = 2;
  r c = 3;

I don't understand why Vim is not including the va on the last two lines. I ran some other tests with Backspace and the Delete key and noticed that neither of these actions are applied to other lines, however I would then expect something like:

var a = 1;
  var b = 2;
  var c = 3;

What is the multiline cursor doing that causes va to be overwritten/ignored? Also, I know that I can select the two columns of spaces and delete them with d then reselect the three lines and type var, but is there a way to do this only having to make the selection once?

deletion then insertion

deletion tests

I've tested this without a vimrc

1 Answer 1


Instead of deleting with d, select spaces in Visual Block Mode and press c, then type var. Difference is that c performs two operations at once - it deletes text and stays in Insert Mode after that.

As for why Vim is not including va - simply it's outside of the visually selected block. I couldn't find anything about that in the :help, but I think Vim is not extending selection left on Backspace and it doesn't repeat all the keystrokes like in a macro. It just copies text inserted within seleted area and pastes it after to the remaining lines of selection.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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