VIM multi-line edit

I always struggle with vim’s multi-line edit (without using dedicated plugins).

Here is a selection of the different commands I use.

Let’s say we have a block on which we want to apply the following actions :

  • Insert “onready " at the beginning of each line
  • Replace get_node(“blah”) by $blah

One way to do it could be :

  • Go to Visual Line mode with ‘V’, eventually select the block with ‘}’
  • Go to Visual Block by using ‘Ctrl-V’
  • Insert “onready " at the beginning with ‘I’ (shift i)
  • Escape, the command is repeated on each line
  • Use ‘normal’ command. Normal takes one parameter, which is a sequence of key you would enter in normal mode. In our example : normal $xx
  • Even if the visual selection has disappeared, it’s possible to re-use it, just use the up arrow to get the last command from history and keep the ‘<,'>