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?


You can use the following pattern in vim:


More info can be found in vim Power of g

Brief explanation of :g


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.