How do I run a one-off macro without recording by executing keystrokes from an expression register?
@='A;<Esc>'<CR>
Recorded macros are powerful, but sometimes you need a quick ephemeral sequence and do not want to occupy a register.
2125 results for "i{ a{"
@='A;<Esc>'<CR>
Recorded macros are powerful, but sometimes you need a quick ephemeral sequence and do not want to occupy a register.
qA
If you finish recording a macro and realize you forgot a step, you don't need to re-record the whole thing.
macros #macros #registers #normal-mode #editing #productivity
:let @a="text"
:let @{register}=".
<C-v>selection r{char}
In visual block mode, pressing r followed by a character replaces every character in the selected rectangle with that character.
"ap, edit, "add
Since macros are stored in registers, you can paste the register content into the buffer, edit it, and yank it back.
:'<,'>norm! A;
The :normal Ex command lets you execute any Normal mode keystrokes on a range of lines simultaneously, turning a single-line operation into a multi-line batch e
editing #editing #normal-mode #ex-commands #visual-mode #text-manipulation
:set viewoptions=cursor,folds,slash,unix
The viewoptions setting is a comma-separated list that determines exactly what :mkview (and the auto-save view pattern) stores in a view file.
:call timer_start(1000, {-> execute('echo "done"')})
Vim's timerstart() function lets you schedule code to run after a specified delay in milliseconds.
Paste with "ap and execute keys manually
To debug a macro, paste its contents into the buffer, read each keystroke, and execute them one at a time to find where the macro goes wrong.
:[range]sort /regex/
The :[range]sort /regex/ command sorts lines while skipping the portion of each line that matches the regex.
:[range]right [width]
Vim's :right command right-aligns text by padding lines with leading spaces up to a given width.
:let @a = expand('%:p')
Named registers are not only for yanked text.
registers #registers #command-line #filename-modifiers #editing
:command Name action
The :command command defines a new user Ex command.
:call setreg('a', @a . 'text', 'l')
How it works Vim provides two functions for advanced register manipulation: setreg() and getreg().
:let @a = @a . "\<CR>extra"
Vim stores macros as plain text in registers — the same registers used for yanked text.
:set winfixwidth winfixheight
How it works When you open new split windows in Vim, the existing windows automatically resize to make room.
{count}|
The command moves the cursor to a specific screen column on the current line.
:silent command
The :silent prefix suppresses all output from a command, including messages and prompts.
<C-v>jjxp
Visual block mode lets you select, cut, and paste rectangular columns of text.
:let @a .= "text"
Vim registers are just strings, and you can read and write them directly using the :let command.