How do I create an insert-mode abbreviation that expands a short sequence into longer text?
The :iabbrev command defines insert-mode abbreviations — short character sequences that automatically expand into longer text when you type a non-keyword char
category:
config
tags:
#insert-mode
#abbreviations
#config
#editing
How do I open just enough folds to see the current line without expanding everything?
zv (view cursor) opens the minimum number of folds needed to make the current line visible — nothing more.
category:
editing
tags:
#folding
#navigation
#editing
How do I delete the line immediately following every line that matches a pattern?
Using :g/pattern/+1d you can delete the line that comes right after each line matching a pattern, in one pass.
category:
command-line
tags:
#ex-commands
#editing
#search
#command-line
How do I use case modifiers like \u and \U in a substitution replacement to change capitalization?
Vim's substitute command supports case-modifier escapes in the replacement string: \u uppercases the next character, \U uppercases all text until \E or end of r
category:
search
tags:
#search
#editing
#substitute
#regex
#ex-commands
How do I apply the last spelling correction to all other identical misspellings in the file?
After correcting a misspelled word with z= (or 1z= for the first suggestion), run :spellrepall to apply that same correction to every other occurrence of the id
category:
editing
tags:
#editing
#search
How do I delete everything typed on the current line without leaving insert mode?
Pressing while in insert mode deletes all characters entered since you last entered insert mode on the current line.
category:
editing
tags:
#insert-mode
#editing
#delete
#normal-mode
How do I reformat a paragraph or motion to fit within the text width without moving my cursor?
The gw operator reformats text to fit within textwidth, just like gq — but with one key difference: gw leaves the cursor in its original position after format
category:
editing
tags:
#editing
#formatting
#text-objects
#normal-mode
How do I run a normal mode command on multiple lines at once?
The :normal Ex command lets you execute any Normal mode keystrokes on a range of lines simultaneously, turning a single-line operation into a multi-line batch e
category:
editing
tags:
#editing
#normal-mode
#ex-commands
#visual-mode
#text-manipulation
How do I open the command-line window while in the middle of typing a command?
While typing in Vim's command line (after pressing :), pressing opens the command-line window with your current, unfinished command already filled in.
category:
command-line
tags:
#command-line
#ex-commands
#editing
How do I use an external formatter with the gq operator in Vim?
Vim's gq operator normally reflows text to fit textwidth, but by setting formatprg you can delegate formatting to any external tool — a language formatter, a
category:
config
tags:
#formatting
#config
#editing
#ex-commands
How do I apply the last substitution's replacement to a different search pattern without retyping it?
The :~ command repeats the last substitution but uses the current search pattern instead of the original pattern.
category:
search
tags:
#search
#editing
#ex-commands
#substitution
How do I quit Vim without saving using a two-keystroke normal mode shortcut?
ZQ is the discard-and-quit counterpart to ZZ.
category:
editing
tags:
#editing
#normal-mode
#ex-commands
How do I find invalid UTF-8 byte sequences in a file in Vim?
The 8g8 command searches forward from the cursor for the first byte that belongs to an invalid UTF-8 sequence.
category:
navigation
tags:
#navigation
#search
#encoding
#unicode
#editing
How do I create new files and directories directly inside Vim's built-in file browser without leaving Vim?
Vim's built-in file explorer netrw (opened with :Explore or :Ex) is more capable than it looks.
category:
buffers-windows
tags:
#buffers
#navigation
#netrw
#editing
How do I join a specific number of lines at once without pressing J multiple times?
The J command joins the current line with the line below, adding a space between them.
category:
editing
tags:
#editing
#normal-mode
#join
#motions
How do I enable Ctrl-A and Ctrl-X to increment and decrement binary numbers like 0b1010 in Vim?
Vim's and commands increment and decrement numbers under the cursor, but by default they only handle decimal and hexadecimal.
category:
config
tags:
#editing
#config
#increment
#normal-mode
#numbers
How do I show both the absolute line number on the current line and relative numbers on all other lines?
:set number relativenumber
Enabling both number and relativenumber simultaneously activates hybrid line numbering: the current line displays its true absolute line number while every othe
category:
config
tags:
#config
#navigation
#normal-mode
#editing
How do I prevent Vim from automatically resizing a window when others open or close?
Setting winfixwidth on a window tells Vim not to adjust its width when other windows are created, closed, or resized with =.
category:
buffers-windows
tags:
#buffers-windows
#config
#editing
#windows
How do I switch from the active command line into the command-line window to edit the command with full Vim power?
Pressing while you are already typing in the Vim command line (:), search line (/ or ?), or input prompt switches you into the command-line window with the curr
category:
command-line
tags:
#command-line
#ex-commands
#editing
#normal-mode
How do I create a fold that spans the current paragraph in manual fold mode?
Combining the fold-creation operator zf with the ap (around paragraph) text object gives you a quick way to collapse any paragraph into a single fold line.
category:
editing
tags:
#folding
#text-objects
#normal-mode
#editing