How do I add a line before each line with “pattern” in it?

You can use the following command to add a line before each line with “pattern” in it:

    :g/pattern/normal! Oi

Alternatively you can yank the line using the Y command and then insert the line using the following command:

    :g/pattern/put!

Comments (1)


Pepsh Pepshinsky

Let’s see you to :help viminfo-file-name (option -i) :set viminfofile=NONE


Speak Your Mind