Johnny Matthews | Edit multiple lines in Vim

How to edit multiple lines at once. I created this mini-guide while using Windows and Powershell, but the information is relevant to Unix-based systems as well. This was written on 31st of December 2020.

Edit multiple lines in Vim

Say we’ve got the following code and we want to move everything between the <table> tags over by a tab:

  1. Move the cursor to the < in <table>.
  2. Press CTRL + v to enter visual-block mode. In Windows this defaults to CTRL + q.
  3. Move to the line with </table>, either by pressing j multiple times, or entering 15j.
  4. Press I. Make sure to use a capital i.
  5. Press tab to move the lines over. Only the top <table> line will move right now.
  6. Press ESC. All the other lines should move over now.

If you would rather add a change to each line after the selected character, use A instead of I.