How do I search and replace text across multiple files in Vim?
:args **/*.py | argdo %s/old/new/gc | update
Vim can perform search-and-replace across multiple files without any plugins by combining the arglist with :argdo.
category:
search
tags:
#search
#substitution
#ex-commands
#productivity
#quickfix
#arglist
How do I capture the output of a Vim command into a register or buffer?
:redir @a | {cmd} | redir END
The :redir command redirects the output of Ex commands to a register, file, or variable instead of displaying it on the screen.
category:
command-line
tags:
#command-line
#ex-commands
#registers
#productivity
#advanced
How do I repeat the last Ex command I ran?
The @: command re-executes the most recently run Ex command (any command starting with :).
category:
command-line
tags:
#command-line
#ex-commands
#repeat
#normal-mode
#productivity
How do I repeat the last substitute command quickly?
The & command in normal mode repeats the last :s substitution on the current line.
category:
search
tags:
#search
#substitution
#ex-commands
#repeat
#normal-mode
How do I reuse my last search pattern in a substitute command without retyping it?
Leaving the search field empty in a :s command tells Vim to reuse the last search pattern from / or .
category:
search
tags:
#search
#substitution
#ex-commands
#regex
#productivity
How do I reverse the order of all lines in a file?
The :g/^/m0 command is a clever use of Vim's global command to reverse every line in the file.
category:
command-line
tags:
#editing
#ex-commands
#global-command
#lines
How do I run a macro across all open buffers at once?
The :bufdo command executes an Ex command in every open buffer, and when combined with :normal @a, it replays macro a across all of them.
category:
macros
tags:
#macros
#buffers
#ex-commands
#automation
#productivity
How do I run a macro only on lines that match a specific pattern?
The :g (global) command combined with :normal @a lets you execute a recorded macro only on lines matching a pattern.
category:
macros
tags:
#macros
#ex-commands
#global-command
#editing
#automation
How do I move the current line up or down without cutting and pasting?
The :m (move) command relocates lines to a new position in the file without using registers.
category:
editing
tags:
#editing
#ex-commands
#lines
#productivity
#mappings
How do I run the same normal mode command on every line in a range?
The :normal (or :norm) command lets you execute normal mode keystrokes from the command line.
category:
command-line
tags:
#editing
#ex-commands
#normal-mode
#productivity
#ranges
How do I paste the last Ex command I ran into my buffer?
The : register holds the most recently executed Ex command.
category:
registers
tags:
#registers
#ex-commands
#normal-mode
#productivity
How do I send the contents of my buffer to a shell command without replacing the text?
The :w !{cmd} command writes the buffer contents to the stdin of an external shell command without modifying the buffer or saving to disk.
category:
command-line
tags:
#command-line
#ex-commands
#shell
#editing
#productivity
How do I navigate compiler errors, grep results, or search matches using the quickfix list?
The quickfix list is Vim's built-in mechanism for navigating a list of file locations — compiler errors, grep results, search matches, or any structured outpu
category:
navigation
tags:
#navigation
#quickfix
#ex-commands
#productivity
#workflow
How do I filter buffer contents through an external shell command?
The :%!{cmd} command pipes the entire buffer through an external shell command and replaces the buffer contents with the command's output.
category:
command-line
tags:
#editing
#ex-commands
#shell
#filtering
#productivity
How do I join multiple lines together with a custom separator like a comma?
Vim's J command joins lines with a single space, but sometimes you need a custom separator like a comma, pipe, or semicolon.
category:
editing
tags:
#editing
#ex-commands
#visual-mode
#substitution
#lines
What is the location list and how does it differ from the quickfix list?
The location list is a per-window variant of the quickfix list.
category:
buffers-windows
tags:
#navigation
#quickfix
#ex-commands
#windows
#productivity
How do I edit and reuse previous Ex commands in a full editing buffer?
The command-line window is a special buffer that shows your entire Ex command history and lets you edit entries using the full power of Vim's normal mode before
category:
command-line
tags:
#command-line
#ex-commands
#history
#editing
#productivity
How do I copy a range of lines to another location without yanking and pasting?
The :t command (short for :copy) duplicates lines from one location to another without touching any registers.
category:
command-line
tags:
#editing
#ex-commands
#lines
#productivity
#ranges
How do I create a temporary scratch buffer for quick notes without saving a file?
:enew | setlocal buftype=nofile bufhidden=wipe noswapfile
A scratch buffer is a temporary, unnamed buffer that exists only in memory — it won't prompt you to save when you close it and leaves no trace on disk.
category:
buffers-windows
tags:
#buffers
#editing
#ex-commands
#productivity
#workflow
How do I delete all lines that do NOT match a pattern?
The :v command (short for :vglobal) is the inverse of :g — it executes a command on every line that does not match the given pattern.
category:
command-line
tags:
#editing
#ex-commands
#search
#filtering
#productivity