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!

Read free Software Algorithms and Computer Science Books by CodeAhoy Learn.

Introduction to Recursion and Backtracking

Sorting Algorithms

Introduction to C Programming Language

And More...

Speak Your Mind