Vim native matching lines

VimAs I grow in my understading of all things Vim, I try to get back to "plain vanilla" Vim as much as I can. It's not that I don't like plugins or find them incredibly useful, it's just when I can do things "Vim's way" there's less overhead from plugins and less potential for conflicts.

There are sometimes when it's nice to be able to find matching lines in a file. When I remember that I did something with a particular spelling or have a method named something else but I don't remember exactly what it is. Sure, I can use CtrlP-Fuzzy or something like that, but for those times when that doesn't exactly fit the bill or those times when I just want something slightly more basic, I can use Vim's built in global command to do just that.

g/<pattern>/p

or

g/<pattern>

When I put "p" as the command on the end of the global command, or I just don't put anything after the pattern, I get a (p)rint of those lines that match. Super simple way to see if there is anything matching in the file.

Always amazed by Vim and all of the things that it can do.

Share this post