How do I run a literal project-wide vimgrep for the word under my cursor?
Answer
:vimgrep /\V<C-r><C-w>/gj **/*
Explanation
When you need a project-wide search for the exact word under your cursor, this pattern avoids regex surprises and immediately populates quickfix. It is especially useful when symbol names contain punctuation that would otherwise need escaping. The result is a reliable search command you can repeat quickly while refactoring.
How it works
:vimgrepsearches files and writes all matches to the quickfix list/.../is the search pattern delimiter\Vswitches Vim regex to very nomagic mode, so most characters are treated literally<C-r><C-w>inserts the current word under the cursor into the command-linegfinds all matches per file (not just the first)jdoes not jump to the first result immediately**/*searches recursively from the current working directory
Example
Suppose the cursor is on api.v2_handler and you want exact matches across a repo:
:vimgrep /\V<C-r><C-w>/gj **/*
:copen
Quickfix is populated with every literal occurrence, ready for navigation with :cnext and :cprev.
Tips
- Narrow file scope for speed:
**/*.goorsrc/**/* - Follow with
:cdoor:cfdofor controlled multi-file edits - If your cursor is on only part of a symbol, visually select text first and insert with
<C-r>"on the command-line