How do I get exact current and total counts for my last search pattern in Vim?
:echo searchcount({'recompute': 1})
Vim can show match counts for your last search, but in large files or after big edits the cached values may lag.
category:
search
tags:
#search
#command-line
#automation
#statusline
#diagnostics
How do I search a project without overwriting the global quickfix list?
:lvimgrep /pattern/gj **/*.js | lopen
When you already rely on the global quickfix list for compiler errors or another search, running :vimgrep can wipe that context.
category:
search
tags:
#search
#command-line
#quickfix
#navigation
How do I uppercase only the current search match using gn as a motion?
gn is often treated as a visual selection command, but it is more powerful when used as a motion target for operators.
category:
search
tags:
#search
#motions
#editing
#normal-mode
How do I search forward but place the cursor at the end of the match?
Most users know /pattern, but fewer use search offsets to control where the cursor lands after the match.
category:
search
tags:
#search
#navigation
#normal-mode
How do I collapse consecutive duplicate words across a file?
:%s/\v<(\w+)\s+\1>/\1/g\<CR>
OCR cleanup, copy-paste artifacts, and rushed note-taking often produce repeated words like the the or is is.
category:
search
tags:
#search
#regex
#substitute
#ex-commands
How do I rerun a previous search pattern from history directly on the / prompt?
/\V<C-r>=histget('/', -2)<CR>
If you often alternate between two complex search patterns, opening q/ each time is slow.
category:
search
tags:
#search
#command-line
#history
#regex
#productivity
How do I search for yanked text literally in Vim without escaping regex characters?
When your yanked text includes regex symbols like .
category:
search
tags:
#search
#registers
#command-line
#regex
How do I replace matches one-by-one using cgn and dot-repeat?
Global substitution is fast, but sometimes you need selective control over each occurrence.
category:
search
tags:
#search
#editing
#normal-mode
#repeat
How do I run a literal project-wide vimgrep for the word under my cursor?
:vimgrep /\V<C-r><C-w>/gj **/*
When you need a project-wide search for the exact word under your cursor, this pattern avoids regex surprises and immediately populates quickfix.
category:
search
tags:
#search
#quickfix
#command-line
#project-workflow
How do I mix very-nomagic and magic sections in a single Vim search?
Sometimes you need one search pattern that treats a literal path strictly while still using regex power for the suffix.
category:
search
tags:
#search
#regex
#pattern
#advanced
How do I limit a search pattern to a specific line range without using :global?
Vim regex supports position atoms that can constrain where a match is allowed to occur.
category:
search
tags:
#search
#regex
#patterns
#navigation
How do I make Vim match only part of a larger regex using \zs and \ze?
When you need to target only a slice of a larger pattern, \zs and \ze are usually cleaner than building lookarounds.
category:
search
tags:
#search
#regex
#patterns
#ex-commands
How do I find trailing whitespace while skipping completely blank lines in Vim?
A plain trailing-whitespace search like /\s\+$ also matches fully blank lines, which is noisy when you only want accidental spaces after real content.
category:
search
tags:
#search
#regex
#whitespace
#cleanup
#patterns
How do I toggle whether / and ? searches wrap around the file?
wrapscan controls what happens when a / or ? search reaches the end (or beginning) of the file.
category:
search
tags:
#search
#options
#command-line
#navigation
How do I jump to non-whitespace text beyond column 80?
When you enforce line-length limits, visual guides show where the boundary is, but they do not help you jump directly to violations.
category:
search
tags:
#search
#regex
#navigation
#formatting
How do I load yanked text into search as a literal pattern without regex escaping headaches?
:let @/='\V'.escape(@", '\\')
When you yank text that contains regex characters like .
category:
search
tags:
#search
#registers
#regex
#command-line
How do I keep project search results window-local with a location list?
:lvimgrep /TODO/j **/* | lopen
When you are working in split-heavy sessions, global quickfix results can become noisy because every window shares the same list.
category:
search
tags:
#search
#quickfix
#buffers
#windows
#command-line
How do I add another project-wide pattern search without replacing my current quickfix results?
:vimgrepadd /pattern/j **/*<CR>
When you are investigating code, you often need to collect several related patterns before deciding what to edit.
category:
search
tags:
#search
#quickfix
#command-line
#navigation
How do I search only files in the argument list and inspect results in a location list?
: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.
category:
search
tags:
#search
#ex-commands
#location-list
#workflow
How do I gather all matches from the current file into a location list without moving the cursor?
When you want a searchable list of matches without leaving your current editing context, :lvimgrep is a strong alternative to regular / navigation.
category:
search
tags:
#search
#quickfix
#location-list
#ex-commands