How do I make a macro that finds and operates on specific patterns?
qq /pattern<CR> {commands} q
By incorporating a search command inside a macro, you can make it jump to the next occurrence of a pattern before performing its edits.
1039 results for "i" a""
qq /pattern<CR> {commands} q
By incorporating a search command inside a macro, you can make it jump to the next occurrence of a pattern before performing its edits.
[p
When you copy code from one indentation level and paste it at another, p preserves the original indentation, leaving your code misaligned.
gg=G
The gg=G command re-indents every line in the current file according to Vim's indentation rules.
mA / 'A
Uppercase marks (A-Z) are global marks — they remember not only the line and column position, but also the file where they were set.
navigation #navigation #marks #normal-mode #buffers #productivity
/[[:digit:][:upper:]]
Vim supports POSIX character classes inside bracket expressions, providing a portable and readable way to match categories of characters.
:redir @a | {cmd} | redir END
The :redir command redirects the output of Ex commands to a register, file, or variable instead of displaying it on the screen.
command-line #command-line #ex-commands #registers #productivity #advanced
F{char}
The F command moves the cursor backward to the previous occurrence of a specified character on the current line.
:autocmd Event pattern command
Autocommands let you execute commands automatically in response to events like opening a file, saving, or changing buffers.
auto-pairs plugin
auto-pairs automatically inserts closing brackets, parentheses, and quotes when you type the opening one.
<C-r>/
Vim stores your last search pattern in the / register.
set statusline=%{MyCustomFunc()}
How it works Vim's statusline supports the %{expr} syntax which evaluates a Vimscript expression and displays the result.
yyp
The yyp command duplicates the current line by yanking it and immediately pasting it below.
:g/pattern/m$
The :g (global) command combined with :m (move) relocates all matching lines to a specified destination.
command-line #command-line #ex-commands #global #editing #organization
:set iskeyword+={char}
iskeyword defines which characters are considered word characters in Vim.
oil.nvim: edit directory listing like a buffer
oil.
<C-f> to scroll forward, <C-b> to scroll backward
How it works Vim provides two commands for scrolling by an entire screen (page) at a time: Ctrl-F (Forward) scrolls the view one full page down through the file
:set foldmethod=marker
Setting foldmethod=marker lets you define fold boundaries using special comment markers — {{{ to start a fold and }}} to end it.
g* and g#
The and # commands search for the exact whole word under the cursor (with word boundaries \).
p (in visual mode)
In visual mode, pressing p replaces the selected text with the contents of the default register.
:r !command
The :r !command command executes a shell command and inserts its output directly into the current buffer below the cursor line.