Today I Learned

hashrocket A Hashrocket project

Search within Selection in Vim

\%V is a useful atom (TIL it's called an atom - and there are a lot of them, see :h pattern-atoms) that can be used to match inside a Visual selection.

Say you have a large file open and want to search for something only within a single area of text, like a method. You can visually select that block of text, enter command mode with :, and prefix the search with \%V to scope the search so that you only get matches inside the selection:

:'<,'>/\%Vsearch_text

You can also use \%V to search and replace.

See More #vim TILs
Every developer at Hashrocket is a Vim expert. Check out our development environment, Dotmatrix, and if you are in Chicago, come to the Vim Chicago Meetup hosted at our Chicago office.