How do I create text abbreviations that auto-expand while typing in Vim?
:iabbrev {abbr} {expansion}
How it works The :iabbrev command creates abbreviations that automatically expand when you type them in insert mode.
Search Vim Tricks
Searching...:iabbrev {abbr} {expansion}
How it works The :iabbrev command creates abbreviations that automatically expand when you type them in insert mode.
\zs and \ze
How it works Vim's \zs (set start) and \ze (set end) atoms let you define which portion of a pattern counts as the actual match, even though the full pattern is
:m {address}
How it works The :m command (short for :move) moves one or more lines to after the specified address.
:set wrap! or :set nowrap
How it works By default, Vim wraps long lines that extend past the window width, displaying them across multiple screen lines.
:g/pattern/t$
How it works The :g (global) command combined with :t (copy) lets you duplicate all lines matching a pattern to a specific location.
[I
How it works The [I command searches the current file (and included files) for the word under the cursor and displays a list of all matching lines with their li
:t {address}
How it works The :t command (short for :copy) copies one or more lines and places them below the specified address.
"ayy "byy "cyy
How it works Vim provides 26 named registers (a through z) that you can use as independent clipboards.
\d \w \s \a \l \u
How it works Vim provides shorthand character classes that save you from writing out full bracket expressions.
:retab
How it works The :retab command replaces all tab characters in the current buffer with the appropriate number of spaces, based on your current tabstop and expan
:'<,'>w filename
How it works Vim's :w command can take a range, and when used with a visual selection, it writes only the selected lines to a file.
yiw
How it works The command yiw yanks (copies) the inner word under the cursor.
.\{-}
How it works In most regex engines, ? or +? make quantifiers non-greedy (matching as little as possible).
/foo\|bar
How it works The \ operator in Vim's search pattern works like a logical OR, letting you match any one of several alternatives.
]s and [s
How it works When spell checking is enabled in Vim with :set spell, misspelled words are highlighted.
q/
How it works Vim keeps a history of all your search patterns.
gD
How it works Vim provides two built-in commands for jumping to where an identifier is defined, without needing tags or an LSP: gd (lowercase) searches backward
:changes
How it works Vim maintains a change list that records the position of every change you make to a buffer.
/\cpattern
How it works By default, Vim searches are case-sensitive: /Hello will not match hello or HELLO.
:'<,'>!command
How it works Vim can pipe selected text through any external shell command, replacing the selection with the command's output.