How do I make Ctrl-A and Ctrl-X increment and decrement alphabetical characters in Vim?
set nrformats+=alpha
By default, Vim's and commands only increment and decrement numbers (decimal, hex, binary).
Search Vim Tricks
Searching...set nrformats+=alpha
By default, Vim's and commands only increment and decrement numbers (decimal, hex, binary).
]# and [#
Vim provides the ]# and [# motions specifically for navigating C preprocessor conditionals.
set nrformats-=octal
By default, Vim treats numbers prefixed with a leading zero (like 007) as octal when you use or to increment or decrement them.
autocmd TextYankPost
The TextYankPost event fires immediately after any yank operation completes — including y, Y, dd, dw, and any other command that writes to a register.
:stopinsert
:stopinsert is an Ex command that immediately exits insert (or replace) mode and returns to normal mode.
command-line #insert-mode #ex-commands #autocommands #normal-mode
CursorHold
The CursorHold autocommand event fires once whenever the cursor has been motionless in normal mode for updatetime milliseconds.
:g/./norm @q
Combining the :global command with :normal lets you run a macro on every non-blank line in one shot.
:'<,'>sort!
The sort! command sorts the selected lines in reverse (descending) order.
readfile() and writefile()
readfile({path}) reads a file and returns its contents as a list of lines, and writefile({list}, {path}) writes a list of lines back to disk.
:set keywordprg
The K key in normal mode looks up the word under the cursor using the program defined by keywordprg.
systemlist()
systemlist({cmd}) runs a shell command and returns the output as a list of strings, one per line — unlike system() which returns everything as a single string
:let @q = 'keystrokes'
You can assign a string directly to any register using :let, turning it into a macro instantly.
:doautocmd
:doautocmd fires any autocommand event manually, exactly as if that event had occurred naturally.
:silent! %normal @q
Combining :silent!, the % range, and :normal @q gives you a powerful pattern for applying a macro across an entire file while gracefully skipping lines that don
v (netrw)
When browsing files in Vim's built-in file manager (Netrw), pressing v on any file opens it in a vertical split to the right.
q?
Vim provides three command-line history windows accessible from normal mode: q: for Ex commands, q/ for forward searches, and q? for backward searches.
<C-r><C-r>
In command-line mode, {reg} inserts a register's contents — but it processes certain sequences, potentially misinterpreting backslashes, pipe characters, or e
<C-v> (command-line mode)
In command-line mode (after : or /), pressing followed by any key inserts that key literally — bypassing all key notation, mappings, and special interpretatio
:sign define and :sign place
Vim's built-in sign system lets you define custom symbols and place them in the sign column — the narrow gutter to the left of line numbers.
winrestcmd()
The winrestcmd() function returns a string of Ex commands that, when executed, restore all window sizes to their state at the time of the call.