How do I use a Vim expression to dynamically compute the replacement in a substitution?
:s/\d\+/\=submatch(0)+1/g
The \= prefix in a :substitute replacement field tells Vim to evaluate the following as a Vimscript expression rather than treating it as a literal string.
category:
registers
tags:
#search
#editing
#ex-commands
#registers
How do I remove trailing spaces only within the currently selected visual block?
Sometimes you need to clean alignment artifacts in a rectangular region without touching the rest of each line.
category:
visual-mode
tags:
#visual-mode
#substitution
#regex
#formatting
#editing
How do I capture Vim command output to a variable or register using the execute() function?
:let @a = execute('messages')
The execute() function (added in Vim 8.
category:
command-line
tags:
#ex-commands
#registers
#macros
#command-line
How do I run an Ex command on all lines between two pattern matches?
Vim's range addressing lets you specify a line range using search patterns instead of explicit line numbers.
category:
search
tags:
#search
#ex-commands
#editing
#command-line
How do I open a floating window showing diagnostic details at the cursor using a built-in Neovim key?
Neovim 0.
category:
buffers-windows
tags:
#diagnostics
#lsp
#floating-window
#neovim
#buffers
#windows
How do I append new keystrokes to an existing macro register without re-recording it?
Re-recording a long macro just to add one extra step is slow and error-prone.
category:
macros
tags:
#macros
#registers
#automation
#ex-commands
How do I quickly re-insert the text I just typed without leaving insert mode?
While in insert mode, pressing re-inserts whatever text you typed during your previous insert session.
category:
editing
tags:
#insert-mode
#editing
#registers
#repeat
How do I capture command-line output directly into a register?
:redir @a | messages | redir END<CR>
When debugging a session or building repeatable edits, it is useful to turn command output into editable text.
category:
registers
tags:
#registers
#command-line
#debugging
#workflow
How do I open the current file in a preview window at a specific pattern?
When you need a second read-only view of the same file, opening more normal splits can disrupt your working layout.
category:
buffers-windows
tags:
#buffers
#windows
#preview
#workflow
How do I open a terminal in the current window instead of a new split?
By default, :terminal opens a new split window for the terminal emulator.
category:
buffers-windows
tags:
#terminal
#buffers
#windows
#shell
#ex-commands
How do I save only real file buffers when running bufdo across many open buffers?
:bufdo if &buftype ==# '' | update | endif
bufdo is powerful for multi-buffer automation, but a naive write pass can error on special buffers (help, terminal, quickfix, prompts).
category:
buffers-windows
tags:
#buffers
#windows
#ex-commands
#automation
#workflow
How do I redisplay the output from the last Ex command that already scrolled away?
Pressing g or q to dismiss it again Example Tips :messages also shows recent messages (and those accumulate across the session), while g< only shows the last pa
category:
command-line
tags:
#command-line
#ex-commands
#output
How do I search literally for the exact text I yanked last?
:let @/ = '\V' . escape(@0, '\')
When the text you yank contains regex characters, a normal / search can produce noisy or surprising matches.
category:
registers
tags:
#registers
#search
#regex
#command-line
How do I execute a command without changing '[ and '] marks in Vim?
Many batch edits in Vim update special marks like '[ and '], which can disrupt follow-up motions or tooling that depends on those positions.
category:
navigation
tags:
#navigation
#marks
#command-line
#refactoring
#editing
How do I reselect the previous visual area and convert it to linewise selection?
gv is well known for reselecting the previous visual area, but pairing it with V is a practical upgrade when your next action needs linewise semantics.
category:
visual-mode
tags:
#visual-mode
#navigation
#editing
How do I edit another file without changing the alternate-file (#) reference?
:keepalt edit path/to/file\<CR>
Experienced Vim workflows often depend on the alternate file (#) for fast toggling with , quick diffs, or two-file review loops.
category:
buffers-windows
tags:
#buffers
#windows
#command-line
#navigation
How do I see all recent Vim messages, errors, and echo output I may have missed?
:messages displays the full log of recent Vim messages — errors, warnings, echo output, and status notifications.
category:
command-line
tags:
#ex-commands
#command-line
How do I inspect only Ex command history so I can quickly rerun a complex command?
When you work with long substitution pipelines or multi-part Ex commands, digging through all history (:history) adds noise.
category:
command-line
tags:
#command-line
#history
#ex-commands
#workflow
How do I let h/l and arrow keys wrap to adjacent lines at line boundaries?
By default, h and l stop at line boundaries.
category:
config
tags:
#config
#navigation
#motions
#editing
How do I create a macro by typing it out instead of recording it interactively?
Recording macros with q works well for simple sequences, but complex macros with special keys can be hard to get right in one take.
category:
macros
tags:
#macros
#registers
#ex-commands