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:
Hi This is Testing insertion of word at the beginning of all lines
Now, do the following and see what happens:
Ctrl+Vto select the first column of text in the lines you want to comment on.
Shift+Iand type the text you want to insert.
1second, and the inserted text will appear on every line.
View all Courses