How do I pipe the entire buffer through an external shell command and replace its contents with the output?
The ! filter command in Vim sends a range of lines to an external program as standard input, then replaces those lines with the program's standard output.
category:
command-line
tags:
#ex-commands
#editing
#command-line
How do I open the file path under my cursor in a new split window?
How it works You may already know that gf opens the file path under the cursor in the current window.
category:
buffers-windows
tags:
#windows
#navigation
#normal-mode
#buffers
How do I insert register contents into the command line?
How it works While typing an Ex command on the command line (after pressing :), you can insert the contents of any register by pressing Ctrl-R followed by the r
category:
registers
tags:
#registers
#ex-commands
#editing
How do I create a recursive macro that repeats itself until it fails?
A recursive macro calls itself at the end of its sequence, creating a loop that automatically repeats until a motion or command fails (such as hitting the last
category:
macros
tags:
#macros
#editing
#normal-mode
#registers
How do I search and replace only within a visual block selection?
The \%V atom restricts a search pattern to match only within the visual selection area, including visual block selections.
category:
search
tags:
#search
#substitute
#visual-mode
#block-mode
#regex
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 see git diff changes in the Vim sign column with vim-gitgutter?
vim-gitgutter is a plugin that shows git diff markers in the sign column (the narrow column to the left of line numbers).
category:
plugins
tags:
#plugins
#editing
#navigation
How do I create a macro that runs itself repeatedly until it fails?
A recursive macro calls itself at the end of its recording, creating a loop that repeats until a motion or command fails (like reaching the end of the file or f
category:
macros
tags:
#macros
#editing
#normal-mode
#automation
#advanced
How do I run a substitution across all files in the argument list?
:argdo %s/old/new/g | update
The :argdo command runs an Ex command on every file in the argument list (the files you opened Vim with, or added via :argadd).
category:
command-line
tags:
#ex-commands
#editing
#command-line
How do I move a split window into its own tab?
The T (Ctrl+w then Shift+t) command moves the current split window into a new tab page.
category:
buffers-windows
tags:
#buffers-windows
#windows
#tabs
#normal-mode
How do I search and replace text only on the current line?
The :s/old/new/g command replaces all occurrences of old with new on the current line only.
category:
search
tags:
#search
#ex-commands
#editing
How do I find accidentally repeated words like 'the the' in a document?
When writing or editing text, repeated words like "the the" or "is is" are a common typo that spell checkers often miss.
category:
search
tags:
#search
#editing
#ex-commands
#formatting
How do I run a Vim command in a restricted sandbox to prevent side effects?
The :sandbox command modifier executes any Ex command in a restricted environment where potentially dangerous operations are blocked.
category:
command-line
tags:
#command-line
#security
#ex-commands
#sandbox
How do I jump to the end of a word in Vim?
The e command moves the cursor to the last character of the current word.
category:
navigation
tags:
#navigation
#motions
#normal-mode
How do I change text in a visual block selection?
In visual block mode, pressing c changes (replaces) all the text in the selected rectangle.
category:
visual-mode
tags:
#visual-mode
#editing
How do I center-align text within a specific width in Vim?
The :center command pads a line with leading spaces so the text is centered within a given width.
category:
editing
tags:
#formatting
#ex-commands
#editing
How do I make a macro that finds and operates on specific patterns?
qq /pattern<CR> {commands} q
By incorporating a search command inside a macro, you can make it jump to the next occurrence of a pattern before performing its edits.
category:
macros
tags:
#macros
#search
#recording
#workflow
#advanced
How do I paste text that automatically matches the indentation of the current line?
When you copy code from one indentation level and paste it at another, p preserves the original indentation, leaving your code misaligned.
category:
editing
tags:
#editing
#indentation
#registers
#normal-mode
How do I auto-indent an entire file in Vim?
The gg=G command re-indents every line in the current file according to Vim's indentation rules.
category:
editing
tags:
#editing
#indentation
#formatting
#normal-mode
How do I set a mark that works across different files?
Uppercase marks (A-Z) are global marks — they remember not only the line and column position, but also the file where they were set.
category:
navigation
tags:
#navigation
#marks
#normal-mode
#buffers
#productivity