How do I restrict a Vim search to match only within a specific range of line numbers?
/\%>5l\%<10l pattern
Vim's \%>{lnum}l and \%5l — matches only at positions after line 5 (i.
640 results for "/pattern"
/\%>5l\%<10l pattern
Vim's \%>{lnum}l and \%5l — matches only at positions after line 5 (i.
:[range]g/pattern/command
The :global command accepts an optional line range prefix that restricts which lines it even considers matching.
\%(pattern\)
In Vim's regex engine, \( and \) create a capturing group whose contents are stored in \1, \2, etc.
\c
Vim lets you embed \c or \C directly inside a search pattern to control case sensitivity for that search only, regardless of your 'ignorecase' and 'smartcase' s
:helpgrep {pattern}
:helpgrep searches the full text of every Vim help file for a pattern and loads all matches into the quickfix list.
:s/pattern/~/
In a Vim substitution, using ~ as the replacement string repeats the replacement text from the most recent :s command.
:ptjump /{pattern}
When a symbol name is ambiguous, jumping directly with :tag can bounce you around the codebase and disrupt your working context.
navigation #navigation #tags #windows #code-navigation #command-line
:packadd cfilter | Cfilter /pattern/
Large quickfix lists are hard to work with when you only care about one subset of matches.
:lvimgrep /{pattern}/j ## | lopen
When you need to run focused searches across a curated set of files, the argument list is a strong scope boundary.
q/k?pattern<CR>
Vim's command-line history window (q: for Ex commands, q/ for search) opens a full editing buffer containing your history.
:g/pattern/z#.5
The :global command is great for finding lines matching a pattern, but by default it only shows the matching lines themselves.
:vimgrep /{pattern}/j **/*
For project-wide searches, :vimgrep is powerful but can feel disruptive if it jumps into files while populating quickfix.
:%sort /[^,]*,/ n
Vim's :sort command accepts a pattern that controls which part of each line is used as the sort key.
:lgrep /pattern/ % | lopen
Quickfix is global, but sometimes you want a narrower search workspace tied to one window.
n
After performing a search with / or ?, pressing n repeats the search in the same direction to find the next match.
"/
Vim stores the last search pattern in the special / register.
:vimgrep /pattern/j **/*
By default, :vimgrep jumps your cursor to the first match it finds, which can be disorienting when you just want to collect results and browse them on your own
:sort r /\w\+$/
The :sort r /{pattern}/ command sorts lines using the text that matches the pattern as the sort key.
//
In Vim, pressing // (two forward slashes) in Normal mode repeats the last search pattern.
\_.
In Vim's regular expressions, .