How do I list only search-pattern history entries in Vim?
Answer
:history /
Explanation
Power users tend to run long, composable searches during refactors, but the default / and ? history navigation can be noisy when command history and search history get mixed in your workflow. :history / gives you a clean, searchable list of only forward-search patterns so you can recover complex regexes quickly.
This is especially useful when a one-off pattern worked earlier and you want to reuse or adapt it without retyping from memory. Instead of pressing / repeatedly and stepping through history blindly, inspect the list, copy exactly what you need, and rerun it intentionally.
How it works
:history /
:historyshows command-line history tables/selects the forward-search history table specifically- Vim prints indexed entries you can inspect and reuse
Example
After running several searches:
/foo\s\+bar
\v\<User(Id|Name)\>
TODO\%>120l
Use:
:history /
You get a focused list of search patterns, making it easy to copy one back into / or into a substitute command.
Tips
- Use
:history ?for backward-search patterns - Open command-line window with
q/to edit a recalled search before executing it - Pair this with
:set hlsearchand:nohlsearchfor faster iterative search tuning