Have you ever faced a situation where you just wanted to have a set of characters prepended to a set of lines in one of your files, and wished that there was an easy way to do it? Well, Vim gives you a very simple way of doing this.
First, let’s create a file with some contents. I have a main.txt with the following contents:
HiThis isTestinginsertion ofword at thebeginning of all lines
Now, do the following and see what happens:
Ctrl+V
to select the first column of text in the lines you want to comment on.Shift+I
and type the text you want to insert.Esc
, wait 1
second, and the inserted text will appear on every line.