How do I execute a command on all the lines containing a pattern?

You can use the “:global” (:g) command to execute a command on all the lines containing a pattern.

    :g/my pattern/d

If you want to use a non-Ex command, then you can use the “:normal” command:

    :g/my pattern/normal {command}

Unless you want the normal mode commands to be remapped, consider using a “:normal!” command instead (note the “!”).

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