Today I Learned

hashrocket A Hashrocket project

Vim Tags in Visual Mode 🏷

This is my 400th TIL! 🎉

I'll file this under 'Vim is endlessly composable'. Today I learned that Vim tags can be used to define a range in visual mode. Here's how you'd fold your code between two Vim tags.

Go to the first tag. If you marked it 1, here's how you'd do that:

m1

Enter visual mode and extend to your second tag 2:

m2

Enter command mode and fold the range:

:fold

Which automatically extends to:

:'<,'>fold

I use this in big markdown files to hide all but the thing I'm currently working on. Enjoy.

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.