How do I apply a recorded macro to a range of lines without re-recording it in Vim?
The :[range]normal @a command runs a recorded macro against every line in a given range.
category:
macros
tags:
#macros
#registers
#ex-commands
#normal-mode
#advanced
How do I automatically apply the preferred LSP code action without a selection prompt in Neovim?
vim.lsp.buf.code_action({ apply = true, filter = function(a) return a.isPreferred end })
When an LSP server marks a code action as isPreferred (e.
category:
plugins
tags:
#normal-mode
#ex-commands
How do I copy lines to a different location in the file without overwriting my yank register?
The :t command (short for :copy) copies addressed lines to a destination line number, leaving the unnamed register untouched.
category:
command-line
tags:
#ex-commands
#editing
#normal-mode
#registers
How do I use Vim as an inline calculator with the expression register?
The expression register ("=) evaluates Vimscript expressions and returns the result.
category:
registers
tags:
#registers
#insert-mode
#expression
#calculator
#vimscript
How do I make Neovim restore the scroll position when navigating back through the jump list?
By default, when you navigate the jump list with (older) or (newer), Neovim restores the cursor's line and column but does NOT restore where the window was scro
category:
navigation
tags:
#neovim
#navigation
#jumplist
#config
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
How do I use Treesitter-aware code folding in Neovim for accurate fold regions based on syntax?
vim.treesitter.foldexpr()
Neovim's built-in Treesitter integration includes vim.
category:
config
tags:
#treesitter
#folding
#config
#neovim
How do I search and replace a word while preserving its case variants in Vim?
The vim-abolish plugin by Tim Pope provides the :Subvert command (abbreviated :S), which performs search-and-replace operations that automatically handle every
category:
plugins
tags:
#plugins
#abolish
#search
#substitute
#refactoring
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 sort lines by a specific column or field in Vim?
Vim does not have a built-in multi-column sort, but you can leverage the external sort command to sort selected lines by any field.
category:
editing
tags:
#editing
#sorting
#ex-commands
#external-commands
#command-line
How do I bookmark a position in one file and jump back to it from any other file?
Uppercase marks (A–Z) are global marks — they persist across files and Vim sessions.
category:
navigation
tags:
#navigation
#marks
#buffers
How do I run a macro until it can no longer proceed without specifying an exact count?
When you give a large count to a macro — such as 100@a — Vim automatically stops replaying the macro as soon as any step inside it fails.
category:
macros
tags:
#macros
#normal-mode
How do I schedule a callback to run after a delay in Neovim using the built-in libuv timer API?
Neovim exposes vim.
category:
plugins
tags:
#config
#editing
How do I paste the contents of a register at a specific line number without moving my cursor?
How it works The :put Ex command pastes the contents of a register after a specified line.
category:
editing
tags:
#editing
#registers
#ex-commands
How do I jump between folds in Vim without opening them?
How it works When working with folded code in Vim, you often want to skip from one fold to another without unfolding anything.
category:
navigation
tags:
#navigation
#folding
#normal-mode
How do I briefly highlight text after yanking it to get visual confirmation of what was copied?
The TextYankPost event fires immediately after any yank operation completes — including y, Y, dd, dw, and any other command that writes to a register.
category:
config
tags:
#config
#autocommands
#registers
#visual-mode
How do I create a self-repeating macro that runs until there is nothing left to process?
@q (inside macro recording)
A recursive macro calls itself as its last action, causing it to repeat indefinitely until it hits an error (like reaching end of file or failing a search).
category:
macros
tags:
#macros
#registers
#normal-mode
#editing
How do I move the current line up or down without cutting and pasting?
The :m (move) command relocates lines to a new position in the file without using registers.
category:
editing
tags:
#editing
#ex-commands
#lines
#productivity
#mappings
How do I use a counter variable inside a Vim macro?
:let i=1 then use <C-r>=i<CR> in macro
By combining a Vimscript variable with the expression register inside a macro, you can create a counter that increments on each replay.
category:
macros
tags:
#macros
#vimscript
#counter
#expression
#advanced
How do I make Vim display partial key sequences and selected character counts in real time?
The showcmd option makes Vim display the currently-typed command in the bottom-right corner of the screen, giving you live feedback as you build up key sequence
category:
config
tags:
#config
#normal-mode
#visual-mode