vimtricks.wiki Concise Vim tricks, one at a time.

How do I jump through several annotation keywords with one search command?

Answer

/\v<(TODO|FIXME|BUG)>

Explanation

When you triage code, jumping among TODO, FIXME, and BUG markers quickly is often more useful than searching each token separately. A single very-magic pattern lets you treat these annotations as one navigation set, so n and N move through all of them in order. This avoids repetitive command-line edits and keeps review flow fast.

How it works

  • / starts a forward search
  • \v enables very-magic mode, so grouping and alternation need fewer escapes
  • < and > apply word boundaries, preventing partial matches inside larger words
  • (TODO|FIXME|BUG) is an alternation group: any one of those labels matches

After the first search, repeat with n (next) and N (previous). Because the full pattern is stored in the search register, you can also reuse it in related commands like :vimgrep /\v<(TODO|FIXME|BUG)>/gj **/*.

Example

Given:

line 1: TODO refactor parser
line 2: NOTE benchmark later
line 3: BUG handle null payload
line 4: FIXME remove legacy branch

Run:

/\v<(TODO|FIXME|BUG)>

Cursor jumps to TODO, then n jumps to BUG, then n again jumps to FIXME.

Tips

  • Add or remove labels by editing only the alternation group
  • Keep labels uppercase for consistency with simple patterns
  • Use :set hlsearch while reviewing so all matching markers stay visible

Next

How do I open the alternate buffer in a new split while keeping my current window unchanged?