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 search across all of Vim's help documentation for a keyword or phrase?
:helpgrep searches the full text of every Vim help file for a pattern and loads all matches into the quickfix list.
category:
search
tags:
#search
#ex-commands
#navigation
How do I insert the result of a Vim expression onto a new line in the buffer?
The :put command inserts the contents of a register as a new line below the cursor.
category:
registers
tags:
#registers
#ex-commands
#editing
How do I assign a macro to a register directly from the command line without recording it?
You can assign a string directly to any register using :let @{reg} = '.
category:
macros
tags:
#macros
#registers
#ex-commands
How do I compare two files side by side using Vim's built-in diff mode?
:vertical diffsplit {file}
Vim has a built-in diff mode that highlights added, removed, and changed lines between two (or more) buffers.
category:
buffers-windows
tags:
#buffers-windows
#ex-commands
#navigation
How do I apply different settings for specific file types in Vim?
autocmd FileType python setlocal expandtab shiftwidth=4
Vim's autocmd FileType lets you apply settings automatically whenever a specific file type is detected.
category:
config
tags:
#config
#ex-commands
#indentation
How do I run a macro on every line in the entire file?
To apply a macro to every line in the file, use :%normal @q.
category:
macros
tags:
#macros
#ex-commands
#normal-mode
How do I navigate between errors and results in the quickfix list?
The quickfix list is Vim's built-in way to collect a list of positions — typically compiler errors, grep results, or linter warnings — and jump between them
category:
buffers-windows
tags:
#buffers
#ex-commands
#navigation
How do I paste my last Ex command into the command line or a buffer?
Vim stores your last executed Ex command in the read-only : register.
category:
registers
tags:
#registers
#ex-commands
#command-line
How do I save a file under a new name in Vim?
The :saveas {filename} command writes the current buffer to a new file and makes that new file the current buffer's file.
category:
command-line
tags:
#ex-commands
#editing
How do I interactively browse and set all Vim options in a single window?
:options opens a special Vim buffer that lists every available option, grouped by category (appearance, editing, search, etc.
category:
config
tags:
#config
#ex-commands
How do I run a macro on only the lines I've visually selected?
When you visually select lines and then type a : command, Vim automatically inserts ' (the visual range marks) into the command line.
category:
macros
tags:
#macros
#normal-mode
#ex-commands
#visual-mode
How do I load project-specific Vim settings automatically when opening files in a directory?
Vim's exrc option tells Vim to look for a .
category:
config
tags:
#config
#vimrc
#project
#ex-commands
How do I open a file in a new tab in Vim?
Vim's tab pages let you keep separate window layouts open at the same time, each with its own set of splits.
category:
buffers-windows
tags:
#buffers
#tabs
#windows
#ex-commands
How do I filter a visual selection through an external shell command?
Vim can pipe a visual selection through any shell command and replace the selection with the command's output.
category:
visual-mode
tags:
#visual-mode
#ex-commands
#external-commands
#filtering
How do I clear search highlights without disabling hlsearch permanently?
After a search in Vim, matched text is highlighted as long as hlsearch is enabled.
category:
search
tags:
#search
#hlsearch
#highlight
#ex-commands
How do I customise Vim's status line to show useful file information?
:set statusline=%f\ %h%m%r%=%-14.(%l,%c%V%)\ %P
Vim's built-in statusline option lets you build a custom status bar that displays exactly the information you want — without any plugin.
category:
config
tags:
#config
#ex-commands
How do I run a command on every line that does NOT match a pattern?
:v (short for :vglobal) is the inverse of :g.
category:
command-line
tags:
#ex-commands
#command-line
#editing
How do I search for a pattern only within a specific range of lines in Vim?
:/start/,/end/s/pattern/replacement/g
You can restrict a substitution to a range defined by two patterns.
category:
search
tags:
#search
#ex-commands
#editing
#substitution
How do I make Vim automatically reload a file when it changes on disk?
The autoread option tells Vim to automatically re-read a file when it detects the file has been changed outside of Vim.
category:
config
tags:
#config
#ex-commands
#buffers