How do you use a macro with the expression register to generate a number sequence?
:let i=1\nqao<C-r>=i\n<Esc>:let i+=1\nq
Use a counter variable with the expression register inside a macro.
2125 results for "i{ a{"
:let i=1\nqao<C-r>=i\n<Esc>:let i+=1\nq
Use a counter variable with the expression register inside a macro.
qa80|i\n<Esc>jq
Record a macro that moves to column 80 using 80 , inserts a newline, and moves to the next line.
qaf,i"<Esc>la"<Esc>q
Record a macro that finds the next comma, inserts a quote before it, moves past the comma, and inserts a quote after.
qa0f lll i-<Esc>llli-<Esc>jq
Record a macro that positions the cursor in a 10-digit number and inserts dashes at positions 3 and 6 to create the format xxx-xxx-xxxx.
qagUiwWq2@a
Macros are most powerful when they encode both the edit and the movement to the next target.
set wildcharm= then nnoremap b :b
wildcharm sets the key that triggers wildmenu expansion inside mappings.
:call setreg('a', @a, 'V')
When you paste from a register, Vim uses that register's stored type: characterwise, linewise, or blockwise.
:let i=1 then use <C-r>=i<CR> in macro
By combining a Vimscript variable with the expression register inside a macro, you can create a counter that increments on each replay.
Use :let i=1 with macro
By combining a Vimscript variable with a macro, you can create sequences with incrementing numbers.
qaI"<Esc>A": "",<Esc>jq
This macro transforms a plain word into a JSON key-value pair format, useful for converting lists of field names into JSON structure.
:let @a = ""
The :let @{register} = "" command empties a register.
:'<,'>norm I//
After making a visual selection, :norm {commands} executes normal-mode keystrokes on every line in the range.
:reg a
The :reg a command shows the contents of register a, which reveals the keystrokes stored in the macro.
:Telescope buffers
:Telescope buffers opens a fuzzy-searchable list of all open buffers.
:redir @a | command | redir END
The :redir command redirects Vim's command output to a register, file, or variable.
:let @a = "Iprefix: \<Esc>"
The :let @a = ".
:for i in range(1,10) | execute "normal @q" | endfor
Using a Vimscript :for loop with execute "normal @q" lets you run a macro with a dynamically computed iteration count and interleave other Ex commands between i
q{a-z}...q
Recording a macro captures a sequence of keystrokes into a register, which you can replay later.
:g/pattern/norm @a
The :g/pattern/norm @a command combines the global command with macro execution.
qaI// <Esc>jq
This macro adds a // comment prefix to the beginning of the current line and moves down.