How do you yank a visual block selection to a register?
<C-v>jjll"ay
Enter visual block mode with , select the block, then "ay to yank the block into register a.
2277 results for "@a"
<C-v>jjll"ay
Enter visual block mode with , select the block, then "ay to yank the block into register a.
:call setreg('a', @a, 'l')
Registers in Vim have a type — characterwise, linewise, or blockwise — that affects how their contents are pasted.
qaI| <Esc>:s/,/ | /g\nA |<Esc>jq
Record a macro that adds pipe delimiters around CSV fields, converting each line to a Markdown table row format.
qad/pattern\nq
Record a macro that deletes from the cursor to the next match of a pattern using d/pattern.
qa{jI## Section \n<Esc>}q
Record a macro that goes to the start of each paragraph and inserts a section header.
:call setreg('q', getreg('a'), getregtype('a'))
Simple register copies can silently change behavior when register type is lost.
:call setreg('a', @a, 'V')
When you paste from a register, Vim uses that register's stored type: characterwise, linewise, or blockwise.
:let @a .= "text"
Vim registers are just strings, and you can read and write them directly using the :let command.
:sb 3
Use :sb (sbuffer) followed by the buffer number to open that buffer in a new horizontal split.
:let @a = @a[:-2]
Macros and named registers are just strings, so you can surgically edit them instead of re-recording from scratch.
:call setreg('a', @a . 'text', 'l')
How it works Vim provides two functions for advanced register manipulation: setreg() and getreg().
qaA <C-r>=strftime('%Y-%m-%d')\n<Esc>jq
Record a macro that appends a date stamp using the expression register with strftime().
qaq:g/pattern/normal "Ayy
Clear register a with qaq, then use :g/pattern/normal "Ayy to append all matching lines to register a.
:redir @a | command | redir END
The :redir command redirects Vim's command output to a register, file, or variable.
:call setreg("a", substitute(getreg("a"), "old", "new", "g"))
The getreg() and setreg() functions let you read and write register contents as plain strings, making it possible to surgically edit a macro without re-recordin
qa/pattern\nyy}pq
Record a macro that searches for a pattern, yanks the matching line, goes to the end of the paragraph, and pastes it.
:resize 10
Use :resize 10 or :res 10 to set the window height to 10 lines.
qayyp:s/old/new/\nq
Record a macro that yanks and pastes the current line, then substitutes text on the new line.
:vertical resize 40
Use :vertical resize 40 to set the window width to 40 columns.
:%s/\d\+/\=submatch(0)*2/g
Use \= to evaluate expressions.