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:
<div>
<table>
<thead>
<tr>
<th>One</th>
<th>Two</th>
<th>Three</th>
</tr>
</thead>
<tbody>
<tr>
<td>Apple</td>
<td>Banana</td>
<td>Carrot</td>
</tr>
</tbody>
<table>
</div>
- Move the cursor to the
<
in<table>
. - Press
CTRL
+v
to entervisual-block
mode. In Windows this defaults toCTRL
+q
. - Move to the line with
</table>
, either by pressingj
multiple times, or entering15j
. - Press
I
. Make sure to use a capitali
. - Press tab to move the lines over. Only the top
<table>
line will move right now. - 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
.