1

I have text in vim editor that I would like to be filtered. I need to show only lines that contains string com:.

How can I achieve that?

3

You can use the following pattern in vim:

:g/com:

More info can be found in vim Power of g

Brief explanation of :g

:[range]g/pattern/cmd

This acts on the specified [range] (default whole file), by executing the Ex command cmd for each line matching pattern (an Ex command is one starting with a colon such as :d for delete). Before executing cmd, "." is set to the current line.

Check vim Power of g for more info.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.