How do I compare the current buffer to another file using Vim's built-in diff mode without leaving the editor?
:diffsplit {file} opens a file in a horizontal split and immediately activates diff mode, highlighting the differences between both buffers.
category:
buffers-windows
tags:
#buffers
#windows
#editing
How do I run a command on all open buffers at once?
:bufdo executes an Ex command in each open buffer in sequence, cycling through every buffer in the buffer list.
category:
buffers-windows
tags:
#buffers
#ex-commands
#editing
#batch
How do I paste from a register while staying in insert mode?
Pressing followed by a register name in insert mode inserts the contents of that register at the cursor position without leaving insert mode.
category:
registers
tags:
#editing
#insert-mode
#registers
#productivity
How do I use a pattern-based range with an offset to operate on lines relative to a search match?
:/pattern/+N and :/pattern/-N
Vim's Ex command ranges can use search patterns as line addresses, and those addresses can include a numeric offset (+N or -N) to target lines relative to the m
category:
command-line
tags:
#ex-commands
#search
#command-line
#editing
How do I run a find-and-replace across multiple files at once using the argument list?
:args **/*.py | argdo %s/old/new/ge | update
Combining :args, :argdo, and :update gives you a powerful in-editor multi-file search and replace without leaving Vim.
category:
command-line
tags:
#ex-commands
#editing
#macros
#search
How do I run a global command only on lines within a visual selection?
How it works The :g (global) command is one of Vim's most powerful features.
category:
visual-mode
tags:
#visual-mode
#ex-commands
#search
#editing
How do I incrementally grow or shrink a split window by a specific number of lines or columns?
:resize adjusts the height of the current window by a relative or absolute amount.
category:
buffers-windows
tags:
#buffers-windows
#ex-commands
How do I browse and edit my backward search history in a full Vim buffer?
Vim provides three command-line history windows accessible from normal mode: q: for Ex commands, q/ for forward searches, and q? for backward searches.
category:
search
tags:
#search
#command-line
#navigation
How do I make the K key look up documentation in a language-specific tool instead of man pages?
The K key in normal mode looks up the word under the cursor using the program defined by keywordprg.
category:
config
tags:
#config
#navigation
#ex-commands
#command-line
How do I hide the command line area in Neovim to gain an extra line of screen space?
Setting cmdheight=0 in Neovim 0.
category:
config
tags:
#config
#neovim
#ui
#screen
How do I peek at a function definition without leaving my current window?
:ptag {identifier} opens a small preview window showing the definition of the given tag, while keeping your cursor in the original window.
category:
navigation
tags:
#navigation
#tags
#windows
How do I align text around a character like = or : using vim-easy-align?
vim-easy-align is a plugin by Junegunn Choi that makes aligning text around delimiters effortless.
category:
plugins
tags:
#plugins
#formatting
#visual-mode
#editing
How do I edit a recorded macro by modifying it as text in a buffer?
Recorded macros are stored as plain text in registers, but editing them by re-recording is tedious for complex sequences.
category:
macros
tags:
#macros
#registers
#editing
How do I record a macro that performs a search and replace on each line?
How it works You can combine Ex commands like :s (substitute) with macro recording to create powerful repeatable find-and-replace operations that go beyond what
category:
macros
tags:
#macros
#ex-commands
#search
#editing
How do I automatically fill a new file with a boilerplate template when creating it in Vim?
autocmd BufNewFile *.py 0r ~/.vim/templates/python.py
When you create a new file in Vim (e.
category:
config
tags:
#config
#autocmd
#editing
#ex-commands
How do I use Vim as an inline calculator with the expression register?
The expression register ("=) evaluates Vimscript expressions and returns the result.
category:
registers
tags:
#registers
#insert-mode
#expression
#calculator
#vimscript
How do I switch between character, line, and block visual modes?
v, V, or Ctrl-V while in visual mode
How it works Vim has three visual modes, and you can switch between them without losing your current selection: v - Characterwise visual mode (select individual
category:
visual-mode
tags:
#visual-mode
#navigation
#editing
How do I insert the filename under the cursor directly into the command line?
While typing a command, inserts the filename under the cursor in the buffer at the command-line prompt.
category:
command-line
tags:
#command-line
#navigation
#editing
How do I control when Vim automatically wraps text or continues comment markers with formatoptions?
The formatoptions setting is a string of single-character flags that governs Vim's automatic text formatting: when lines wrap, whether comment syntax continues
category:
config
tags:
#config
#formatting
#ex-commands
#indentation
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