How do I redraw the screen with the cursor line at center or bottom and move to the first non-blank character?
Vim has scroll-positioning commands that come in two flavors: those that leave the cursor in the current column (zz, zt, zb) and those that also move the cursor
category:
navigation
tags:
#navigation
#normal-mode
#scrolling
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 create a Vim mapping where the keys it produces are computed dynamically at runtime?
:nnoremap <expr> {key} {expression}
The argument to any map command (:nmap, :inoremap, etc.
category:
config
tags:
#config
#macros
#insert-mode
#normal-mode
#ex-commands
How do I run the same command across all open buffers at once?
When you need to apply the same change to every file you have open in Vim, switching to each buffer manually is tedious and error-prone.
category:
buffers-windows
tags:
#buffers
#ex-commands
#editing
#batch
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 macro across all open buffers at once?
The :bufdo command executes an Ex command in every open buffer, and when combined with :normal @a, it replays macro a across all of them.
category:
macros
tags:
#macros
#buffers
#ex-commands
#automation
#productivity
How do I selectively replace occurrences one at a time, choosing to apply or skip each match?
The n.
category:
search
tags:
#search
#editing
#normal-mode
#dot-repeat
#motions
How do I change each occurrence of a search match one at a time, confirming each with the dot command?
The cgn + .
category:
search
tags:
#search
#editing
#normal-mode
#motions
How do I make a macro prompt for user input at a specific point during its execution?
<C-r>=input('Enter: ')<CR>
By embedding =input('prompt: ') inside a recorded macro, you can pause the macro at any point to ask for user input and insert the result.
category:
macros
tags:
#macros
#insert-mode
#registers
#editing
How do I run a command on every line in the quickfix list at once?
:cdo executes an Ex command on every entry in the quickfix list in sequence, visiting each match in turn.
category:
command-line
tags:
#ex-commands
#search
#editing
#quickfix
How do I run a macro a specific number of times at once?
Prefix any macro execution with a count to repeat it that many times in a single command.
category:
macros
tags:
#macros
#registers
#normal-mode
How do I open or close a fold and all its nested folds at once?
zO and zC are the recursive counterparts to zo and zc.
category:
editing
tags:
#folding
#navigation
#editing
#normal-mode
How do I insert the same text at the start (or end) of multiple lines simultaneously?
<C-v>{motion}I{text}<Esc>
Visual block mode () lets you select a rectangular region across multiple lines.
category:
visual-mode
tags:
#visual-mode
#editing
#normal-mode
How do I change the same column of text across multiple lines at once?
<C-v>jjc replacement<Esc>
Visual block mode's change command lets you replace a rectangular column of text across multiple lines in a single operation.
category:
visual-mode
tags:
#editing
#visual-mode
#block-mode
#normal-mode
#productivity
How do I edit multiple lines at once using multiple cursors in Vim?
The vim-visual-multi plugin (formerly vim-multiple-cursors) brings VS Code-style multiple cursor editing to Vim.
category:
plugins
tags:
#plugins
#visual-multi
#editing
#multiple-cursors
#refactoring
How do I edit multiple locations simultaneously like multiple cursors?
<C-n> to select (vim-visual-multi)
vim-visual-multi provides VS Code-style multiple cursor support for Vim.
category:
plugins
tags:
#plugins
#editing
How do I control exactly where a new split window appears in Vim?
By default, Vim places horizontal splits below and vertical splits to the right (controlled by splitbelow and splitright).
category:
buffers-windows
tags:
#buffers
#windows
#ex-commands
#splits
What is the difference between zt and z-Enter when scrolling the current line to the top of the screen?
Both zt and z scroll the view so that the current line lands at the top of the screen, but they differ in one small but important way: z also moves the cursor t
category:
navigation
tags:
#navigation
#normal-mode
What is the difference between backtick and apostrophe when jumping to marks?
Vim has two ways to jump to marks: backtick (` `) jumps to the exact line AND column, while apostrophe (') jumps to the line only, positioning the cursor at the
category:
navigation
tags:
#navigation
#marks
#positioning
#motions
How do I record a macro to wrap each line in HTML tags?
qaI<li><Esc>A</li><Esc>jq
This macro wraps each line in tags by inserting the opening tag at the start and appending the closing tag at the end.
category:
macros
tags:
#macros
#editing