Vim Tips Wiki

Look up tags using regular expressions

Redirected from VimTip1018

1,624pages on
this wiki
Add New Page
Talk0 Share
Tip 1018 Printable Monobook Previous Next

created 2005 · complexity intermediate · author Craig Emery · version 6.0

I use tags a lot. I usually have one tag file per subsystem and I add and remove them from my tags variable when my "focus" changes.

Anyway, one circumstance that I find myself in some times is that I know a function exists and I have a good idea what it's called but can't remember the exact name.

Scenario: find the event handler function.

Ambiguity: Is it handleEvent, HandleEvent, handle_the_event?

Solution: Use regular expressions and command completion to guess.

:tj /handle.*event<C-D>

When using the tag family of commands you can search through tags when the first character of the keyword you give to the command is /

When used in conjunction with command-line completion (using CTRL-D) you get "instant" feedback on whether your regular expression was close enough.

In a simpler scenario all tag searches using the / character are case insensitive, so even when used without a regular expression, / can help you find the tag you're looking for.


I should point out that if you have ignorecase (ic) set, then the tags family of commands all do tag lookup in a case insensitive manner, so using / without a regular expression is really just a one-off short-cut to dong a tags lookup whilst ignoring case. It really just saves you setting ic and then unsetting it afterwards.

Or you can use /\cregexp for searching (adding \c after / makes the search case insensitive).

Ad blocker interference detected!

Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.

Also on Fandom

Random Wiki