How do I search for a pattern across all files in my project without leaving Vim?
:vimgrep /pattern/ searches recursively through all files in the current working directory tree using Vim's own regex engine, populating the quickfix list with
category:
search
tags:
#search
#quickfix
#ex-commands
#navigation
How do I search for a pattern only on a specific line number or at a specific column position?
Vim's \%l and \%c pattern atoms anchor a search to a particular line number or column, enabling surgical searches and substitutions that standard regex cannot e
category:
search
tags:
#search
#regex
#ex-commands
How do I extract the directory, filename, or extension from the current file path inside a Vim command?
Vim's filename modifiers let you derive path components from the current buffer's filename directly on the command line.
category:
command-line
tags:
#ex-commands
#command-line
#editing
How do I apply a macro to every line in a specific range without running it manually each time?
The :[range]normal @q command replays the macro in register q on every line within a given range.
category:
macros
tags:
#macros
#normal-mode
#ex-commands
#ranges
How do I run a command on every individual quickfix entry in Vim?
:cdo {cmd} executes a command at every entry in the quickfix list, visiting each location in turn.
category:
command-line
tags:
#command-line
#ex-commands
#search
#editing
How do I run a normal mode command on every line in a visual selection?
After making a visual selection, :norm {commands} executes normal-mode keystrokes on every line in the range.
category:
visual-mode
tags:
#visual-mode
#editing
#ex-commands
#normal-mode
How do I run a Vim command without triggering any autocommands?
The :noautocmd modifier (abbreviated :noa) runs any subsequent Ex command while temporarily disabling all autocommand events.
category:
command-line
tags:
#ex-commands
#editing
#config
How do I uppercase or lowercase matched text directly in a substitute command?
Vim's substitute replacement string supports special case-transform atoms that change the case of matched text without requiring a second pass or an external to
category:
editing
tags:
#editing
#search
#ex-commands
#formatting
How do I define or modify a macro without recording keystrokes?
Instead of recording a macro with q, you can assign any string directly to a named register using :let @{register} = 'keys'.
category:
macros
tags:
#macros
#registers
#ex-commands
#normal-mode
How do I undo changes back to how the file looked 5 minutes ago?
Vim's undo history is not just a linear list of changes — it records timestamps too.
category:
editing
tags:
#undo-redo
#ex-commands
#editing
#normal-mode
How do I open a file by name without knowing its full path?
The :find command searches for a file by name across all directories listed in Vim's path option, so you can open files without typing full paths.
category:
navigation
tags:
#navigation
#ex-commands
#buffers
#editing
How do I pipe a range of lines through an external command and replace them with the output?
The ! operator filters the text covered by a motion through an external shell command, replacing the original lines with the command's stdout.
category:
editing
tags:
#editing
#ex-commands
#normal-mode
#formatting
How do I run a substitute command without overwriting my last search pattern?
:keeppatterns %s/old/new/g
The :keeppatterns modifier runs any Ex command without modifying Vim's last search pattern (stored in @/).
category:
command-line
tags:
#search
#ex-commands
#command-line
#substitute
#registers
How do I apply a normal mode command to every line in a range at once?
:normal (abbreviated :norm) executes a sequence of normal-mode keystrokes on each line of an address range.
category:
command-line
tags:
#ex-commands
#editing
#normal-mode
#macros
How do I copy lines to a different location in the file without overwriting my yank register?
The :t command (short for :copy) copies addressed lines to a destination line number, leaving the unnamed register untouched.
category:
command-line
tags:
#ex-commands
#editing
#normal-mode
#registers
How do I run a recorded macro across multiple files at once?
Combining :argdo with :norm @a lets you apply a recorded macro to every file in Vim's argument list — a powerful pattern for bulk refactoring across a project
category:
macros
tags:
#macros
#ex-commands
#editing
#buffers
How do I filter the entire buffer (or a range of lines) through an external shell command?
The ! operator pipes text through a shell command, replacing the selected lines with the command's output.
category:
command-line
tags:
#ex-commands
#editing
#command-line
How do I sort lines and remove duplicates in one command?
The :sort u command sorts all lines in the buffer (or a selected range) alphabetically and removes duplicate lines in a single pass.
category:
editing
tags:
#editing
#ex-commands
#formatting
How do I define or fix a macro using Vimscript instead of re-recording it?
Macros in Vim are just text stored in named registers.
category:
macros
tags:
#macros
#registers
#ex-commands
How do I insert the result of a Vim expression or calculation directly into text?
The expression register ("=) lets you evaluate any Vim expression and insert its result as text.
category:
registers
tags:
#registers
#insert-mode
#editing
#ex-commands