How do I display all the lines in the current buffer that contain a specified pattern?

You can use the following command to display all the lines in the current buffer that contain a specified pattern:

    :g//p

For example, the following command will display all the lines in the current buffer that contain “vim”:

    :g/vim/p

Since :p is the default command to be executed for the ex command :g, you can also use:

    :g/vim

If you also want the corresponding line numbers, then you can use the following command:

    :g//#

Comments (1)


Pepsh Pepshinsky

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


Speak Your Mind