How do I run a full-buffer substitution without disturbing marks, jumplist, or search history?
:lockmarks keepjumps keeppatterns %s/foo/bar/ge
Large substitutions are efficient, but they often leave side effects: your last search changes, your jumplist gets noisy, and marks can shift in ways that break
category:
command-line
tags:
#command-line
#editing
#substitution
#navigation
How do I run the same command across all windows, buffers, or tabs?
:windo / :bufdo / :tabdo {command}
Vim's do commands iterate over collections and execute a command in each context.
category:
buffers-windows
tags:
#buffers
#windows
#tabs
#batch-editing
#ex-commands
How do I enable a popup menu for command-line tab completion in Neovim?
Setting wildoptions=pum tells Neovim to use its popup menu for command-line tab completion instead of the traditional horizontal wildmenu bar.
category:
config
tags:
#config
#completion
#command-line
How do I insert the current date or time into the buffer using Vim's built-in expression evaluation?
:put =strftime('%Y-%m-%d')
The :put = command inserts the result of a Vimscript expression directly into the buffer as a new line.
category:
editing
tags:
#editing
#ex-commands
#registers
#insert-mode
How do I run a targeted health check for a specific Neovim plugin or module to diagnose issues?
:checkhealth {module} runs the health check only for the specified module, making it much faster than the full :checkhealth which interrogates every registered
category:
command-line
tags:
#neovim
#diagnostics
#debugging
#plugins
#health
How do I execute the contents of a register as an Ex command?
How it works The command :@a executes the contents of register a as an Ex command.
category:
registers
tags:
#registers
#ex-commands
#editing
How do I change which characters Vim treats as part of a word for motions and text objects?
iskeyword defines which characters are considered word characters in Vim.
category:
config
tags:
#config
#editing
#search
How do I append text to the end of multiple lines that have different lengths?
Visual block mode normally selects a fixed-width column, which makes appending tricky when lines have different lengths.
category:
visual-mode
tags:
#visual-mode
#editing
#insert-mode
How do I move all lines matching a pattern to the top or bottom of a file?
The :global command combined with :move lets you restructure a file by relocating all lines that match a pattern.
category:
editing
tags:
#ex-commands
#editing
#text-objects
How do I scroll the view horizontally so the cursor sits at the leftmost or rightmost visible column?
When nowrap is set and lines extend beyond the screen width, zs and ze snap the horizontal scroll position so the cursor sits exactly at the left or right edge
category:
navigation
tags:
#navigation
#scrolling
How do I repeat my last change on every line in a visual selection?
The :'norm .
category:
visual-mode
tags:
#visual-mode
#editing
#normal-mode
#repeat
#dot-operator
How do I open a file in a read-only split window in Vim?
The :sview command opens a file in a horizontal split window with the buffer set to read-only.
category:
buffers-windows
tags:
#buffers-windows
#windows
#navigation
#ex-commands
How do I add custom filetype detection for a new file extension without modifying Vim's built-in filetypes?
Vim automatically sources every file in ftdetect/ directories on the runtimepath when filetype detection runs.
category:
plugins
tags:
#config
#ex-commands
How do I create a key mapping that behaves differently depending on context?
:nnoremap <expr> j (v:count == 0 ? 'gj' : 'j')
Expression mappings use the flag to evaluate a Vimscript expression at the time the key is pressed.
category:
config
tags:
#config
#normal-mode
#ex-commands
#navigation
How do I reformat text to fit the line width without moving the cursor?
The gw operator reformats text just like gq, but leaves the cursor in its original position after reformatting.
category:
editing
tags:
#editing
#formatting
#motions
#text-objects
How do I set a bookmark that takes me back to a specific line in any file?
Uppercase marks (A–Z) are global marks in Vim — they persist across files and even across sessions (when viminfo or shada is configured).
category:
navigation
tags:
#navigation
#marks
#buffers
#normal-mode
How do I open or close every fold in the entire file at once?
When working with a heavily folded file, manually opening or closing each fold is tedious.
category:
editing
tags:
#folding
#navigation
#editing
#normal-mode
How do I paste text and leave the cursor after the pasted content instead of on it?
The standard p command pastes text after the cursor but leaves the cursor at the beginning of the pasted text.
category:
navigation
tags:
#editing
#registers
#normal-mode
#paste
How do I insert text at the beginning of multiple lines at once using visual block mode?
Visual block mode's I command lets you type once and have the text inserted at the cursor column across all selected lines simultaneously.
category:
visual-mode
tags:
#visual-mode
#editing
#normal-mode
How do I edit a recorded macro without re-recording it from scratch?
Macros are stored as plain text in named registers.
category:
macros
tags:
#macros
#registers
#editing