How do I prompt the user for input in the middle of a mapping or Vimscript function?
The built-in input() function pauses execution, displays a prompt at the bottom of the screen, and returns whatever the user types before pressing Enter.
category:
macros
tags:
#macros
#editing
#ex-commands
#insert-mode
How do I append additional keystrokes to a recorded macro using Vimscript without re-recording it?
The string concatenation assignment :let @q .
category:
macros
tags:
#macros
#registers
#editing
#normal-mode
How do I delete consecutive duplicate lines from a file using a single Ex command?
The :g command with a backreference pattern can detect and delete consecutive duplicate lines in one pass.
category:
command-line
tags:
#ex-commands
#search
#editing
#normal-mode
How do I force a Vim operator to act linewise even when the motion is normally characterwise?
In operator-pending mode — the brief state after typing an operator like d, c, or y but before entering the motion — you can prefix the motion with v, V, or
category:
editing
tags:
#editing
#motions
#normal-mode
#operators
How do I visually select multiple paragraphs or text objects at once using a count prefix?
In Vim, text objects accept a count prefix in visual mode, letting you select multiple consecutive text objects in one keystroke.
category:
visual-mode
tags:
#visual-mode
#text-objects
#motions
#editing
How do I delete each line matching a pattern along with a fixed number of lines that follow it?
Inside a :global command, .
category:
command-line
tags:
#ex-commands
#global
#delete
#editing
#command-line
How do I push or pull a single diff hunk between buffers with a single keystroke in diff mode?
In Vim's diff mode, dp (diff put) and do (diff obtain) are single-keystroke shorthands for :diffput and :diffget.
category:
buffers-windows
tags:
#diff
#buffers-windows
#editing
#normal-mode
How do I set Vim options from a Lua config in Neovim using vim.opt?
Neovim's vim.
category:
config
tags:
#config
#neovim
#lua
#options
#editing
How do I use the filename under the cursor as a value in a Vim mapping or command?
The expand('') function returns the filename that Vim sees under the cursor — the same file that gf would open.
category:
command-line
tags:
#command-line
#ex-commands
#navigation
#editing
#motions
How do I open a file under the cursor in a new split and jump to its line number in Vim?
F opens the filename under the cursor in a new horizontal split window and jumps to the line number that follows the filename.
category:
buffers-windows
tags:
#navigation
#buffers-windows
#windows
#editing
How do I edit a recorded macro by treating it as plain text?
When you record a macro and realize it has a mistake, the easiest fix is to paste the macro's keystrokes as text, edit them, and yank the corrected version back
category:
macros
tags:
#macros
#registers
#editing
#normal-mode
How do I open folds one level at a time in Vim without revealing all nested folds at once?
zr ("reduce" fold level) decrements the global foldlevel option by 1, opening the next layer of folds across the entire file.
category:
editing
tags:
#folding
#editing
#normal-mode
How do I indent all lines from the cursor to the matching closing bracket in Vim?
Vim's > operator (indent) works with any motion or text object — including %, which jumps to the bracket, parenthesis, or brace matching the one under the cur
category:
editing
tags:
#editing
#indentation
#text-objects
#normal-mode
#motions
How do I use a named mark as a motion target for operators like delete, yank, or indent in Vim?
Named marks are not just jump destinations — they serve as motion targets for any operator.
category:
navigation
tags:
#navigation
#marks
#editing
#motions
#normal-mode
How do I swap two adjacent words on a line using a substitute command in Vim?
:s/\v(\w+)\s+(\w+)/\2 \1/
By using capture groups in a substitute command with very magic mode (\v), you can swap two adjacent words in a single operation.
category:
search
tags:
#search
#editing
#substitute
#regex
#text-objects
How do I restrict the :global command to operate on only a portion of the file?
:[range]g/pattern/command
The :global command accepts an optional line range prefix that restricts which lines it even considers matching.
category:
command-line
tags:
#command-line
#global
#ex-commands
#editing
How do I join all soft-wrapped lines in each paragraph into a single line?
The :g/^.
category:
command-line
tags:
#command-line
#editing
#global
#formatting
#paragraphs
How do I shift-indent all lines from the current cursor position to the end of the file?
The >G command applies a right-indent shift to every line from the cursor through the last line of the buffer.
category:
editing
tags:
#editing
#indentation
#motions
#normal-mode
How do I populate the argument list with a glob pattern to work across multiple files?
The :args command sets Vim's argument list to all files matching a glob pattern.
category:
command-line
tags:
#command-line
#buffers
#ex-commands
#editing
How do I replace exactly N consecutive characters with the same character without entering visual mode?
The {count}r{char} command replaces a precise number of characters starting at the cursor position with a single repeated character.
category:
editing
tags:
#editing
#normal-mode
#replace
#motions