How do I programmatically set the contents of a register from the command line?
The :let @{reg} = expr command lets you assign any string or expression directly into a named register without entering insert mode or performing a yank.
category:
registers
tags:
#registers
#ex-commands
#macros
#normal-mode
How do I make CursorHold events fire faster so plugins and diagnostics respond more quickly?
Vim's updatetime option controls two things: how quickly the swap file is written after you stop typing, and how many milliseconds of inactivity before the Curs
category:
config
tags:
#config
#performance
#autocmd
#cursorhold
#plugins
How do I create shortcuts for long Ex commands I type frequently?
:cabbrev (command-line abbreviation) lets you define short aliases for longer Ex commands.
category:
command-line
tags:
#command-line
#ex-commands
#config
How do I replace a line (or range) with the output of a shell command in Vim?
:.
category:
command-line
tags:
#ex-commands
#editing
#command-line
How do I replace the next search match and repeat it easily with dot?
The cgn command combines the change operator with the gn motion to change the next occurrence of your last search pattern.
category:
editing
tags:
#editing
#search
#repeat
#normal-mode
#productivity
How do I anchor a search or substitution pattern to the current cursor position?
The \%# atom in Vim's regex engine matches the exact position of the cursor — zero-width, between characters.
category:
search
tags:
#search
#normal-mode
#ex-commands
#editing
How do I move the cursor to the end of a line?
The $ command moves the cursor to the last character of the current line.
category:
navigation
tags:
#navigation
#motions
#normal-mode
How do I display the contents of only certain registers instead of all of them at once?
The :reg (alias :registers) command accepts a string of register names as its argument.
category:
registers
tags:
#registers
#ex-commands
#normal-mode
How do I access event-specific data like yank contents or inserted characters inside a Vim autocommand?
The v:event dictionary is populated inside certain autocommand callbacks with data specific to that event.
category:
config
tags:
#config
#ex-commands
#registers
How do I always access my last yanked text regardless of deletes?
Register 0 (the yank register) always contains the text from your most recent yank command — and unlike the unnamed register, it is never overwritten by delet
category:
registers
tags:
#registers
#paste
#yank
#workflow
How do I run a literal project-wide vimgrep for the word under my cursor?
:vimgrep /\V<C-r><C-w>/gj **/*
When you need a project-wide search for the exact word under your cursor, this pattern avoids regex surprises and immediately populates quickfix.
category:
search
tags:
#search
#quickfix
#command-line
#project-workflow
How do I refer to the current filename, extension, or directory in Vim ex commands?
Vim's filename modifiers let you derive path components from the current file's name directly inside ex commands.
category:
command-line
tags:
#command-line
#ex-commands
#buffers
How do I refactor a recorded macro by rewriting its keystrokes with substitute()?
:let @q = substitute(@q, 'foo', 'bar', 'g')
Recorded macros are plain text stored in registers, which means you can refactor them instead of re-recording from scratch.
category:
macros
tags:
#macros
#registers
#automation
#ex-commands
How do I select the contents inside curly braces?
The vi{ command visually selects everything inside the nearest pair of curly braces {}, without selecting the braces themselves.
category:
visual-mode
tags:
#visual-mode
#text-objects
#editing
#normal-mode
How do I show both the absolute line number on the current line and relative numbers on all other lines?
:set number relativenumber
Enabling both number and relativenumber simultaneously activates hybrid line numbering: the current line displays its true absolute line number while every othe
category:
config
tags:
#config
#navigation
#normal-mode
#editing
How do I append extra keystrokes to a recorded macro from the command line without re-recording it?
Live macro recording is fast, but adjusting the tail of a macro by re-recording can be risky once it already works in most places.
category:
macros
tags:
#macros
#registers
#automation
#normal-mode
#workflow
How do I set up a local leader key for file-type-specific mappings that don't conflict with global mappings?
:let maplocalleader = ','
Vim provides two separate leader keys: (global) and (local to the current buffer).
category:
config
tags:
#config
#normal-mode
#ex-commands
How do I convert a recorded macro into a permanent key mapping?
:let @q then use in nnoremap
Macros are stored in registers as plain keystroke strings.
category:
macros
tags:
#macros
#config
#vimrc
#mappings
#workflow
How do I move to the first non-blank character of a line?
The ^ command moves the cursor to the first non-blank character of the current line.
category:
navigation
tags:
#navigation
#motions
#normal-mode
How do I search for yanked text literally in Vim without escaping regex characters?
When your yanked text includes regex symbols like .
category:
search
tags:
#search
#registers
#command-line
#regex