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
How do I execute the current line as a shell command and insert the output?
The :.
category:
command-line
tags:
#editing
#ex-commands
#shell
#filtering
#productivity
How do I do math calculations without leaving insert mode?
The expression register (=) lets you evaluate Vimscript expressions on the fly and insert the result directly into your text.
category:
registers
tags:
#editing
#insert-mode
#registers
#productivity
#math
How do I paste the result of a calculation or expression in normal mode?
The expression register ("=) lets you evaluate any Vimscript expression and paste the result directly into your buffer from normal mode.
category:
registers
tags:
#registers
#editing
#normal-mode
#productivity
#math
How do I autocomplete file paths while typing in insert mode?
The command triggers filename completion in insert mode.
category:
editing
tags:
#editing
#insert-mode
#completion
#file-management
#productivity
How do I add more commands to a macro I already recorded?
If you finish recording a macro and realize you forgot a step, you don't need to re-record the whole thing.
category:
macros
tags:
#macros
#registers
#normal-mode
#editing
#productivity
How do I perform the same operation across multiple files using the argument list?
:args **/*.js | argdo %s/old/new/ge | update
The argument list (arglist) is Vim's mechanism for loading a set of files and running commands across all of them.
category:
command-line
tags:
#command-line
#ex-commands
#arglist
#productivity
#batch
#editing
How do I auto-indent a block of code using visual mode?
Pressing = in visual mode auto-indents the selected lines according to Vim's built-in indentation rules.
category:
visual-mode
tags:
#editing
#visual-mode
#indentation
#formatting
#productivity
How do I quickly replace the text inside quotes without manually selecting it?
The ci" command deletes everything inside the nearest pair of double quotes and drops you into insert mode, ready to type the replacement.
category:
editing
tags:
#editing
#text-objects
#normal-mode
#productivity
How do I change text from the cursor up to a specific character?
The ct{char} command deletes everything from the cursor up to (but not including) the specified character and drops you into insert mode.
category:
editing
tags:
#editing
#motions
#normal-mode
#text-objects
#productivity
What is the difference between cw and ciw when changing a word?
The cw and ciw commands both change a word, but they behave differently depending on cursor position.
category:
editing
tags:
#editing
#text-objects
#motions
#normal-mode
#productivity
How do I append text to the end of multiple lines at once using visual block mode?
Visual block mode combined with $A lets you append text to the end of multiple lines simultaneously, even when those lines have different lengths.
category:
visual-mode
tags:
#editing
#visual-mode
#block-mode
#productivity
#insert-mode
How do I specify line ranges in Ex commands to target specific parts of a file?
Every Ex command in Vim can be preceded by a range that specifies which lines it should operate on.
category:
command-line
tags:
#command-line
#ex-commands
#ranges
#editing
#productivity
How do I set up auto-correct abbreviations in Vim to fix common typos?
Vim's abbreviation system automatically expands short text sequences as you type, making it perfect for auto-correcting typos, inserting boilerplate snippets, o
category:
config
tags:
#editing
#insert-mode
#config
#productivity
#auto-correct
How do I replace the next search match and repeat it easily with dot?
The cgn command combines the change operator with the gn motion to change the next occurrence of your last search pattern.
category:
editing
tags:
#editing
#search
#repeat
#normal-mode
#productivity
How do I repeat the last change in Vim?
The .
category:
editing
tags:
#editing
#normal-mode
#productivity
#motions