How do I access the alternate file register?
"# register
The # register contains the name of the alternate file — the previously edited file in the current window.
351 results for "registers"
"# register
The # register contains the name of the alternate file — the previously edited file in the current window.
:put =toupper(@")
Registers in Vim are not only for raw replay; you can treat them as string data and transform them at paste time.
registers #registers #expression-register #editing #vimscript
".
The .
"=2+3<CR>p
The expression register = evaluates a Vimscript expression and stores the result.
:call setreg('q', getreg('a'), getregtype('a'))
Simple register copies can silently change behavior when register type is lost.
visual select + d, move, P
To swap two pieces of text, delete the first selection, navigate to the second, select it, and paste.
"+yy
The "+yy command yanks the current line directly to the system clipboard register, making it available for pasting in other applications.
"+y and "+p
The "+ register is linked to the system clipboard.
<C-r><C-o>a
When you paste multiline snippets from a register while in Insert mode, default insertion can trigger indentation and formatting side effects line by line.
registers #registers #insert-mode #formatting #indentation #editing
:let @a = "Iprefix: \<Esc>"
The :let @a = ".
:let @a=@1
When you delete full lines repeatedly, Vim rotates those deletions through numbered registers.
<C-r>{reg} in command line
While on the : command line, pressing followed by a register name inserts that register's contents.
:let @a = @a . "\<CR>extra"
Vim stores macros as plain text in registers — the same registers used for yanked text.
:call setreg('a', @a, 'l')
Registers in Vim have a type — characterwise, linewise, or blockwise — that affects how their contents are pasted.
:call setreg('a', "foo\nbar", 'b')
Most register examples focus on interactive yanks, but setreg() lets you construct registers programmatically, including their type.
:call setreg('b', getreg('a'), getregtype('a'))
Plain register copies like :let @b = @a move text, but they can lose important metadata about register type.
qaciw"<C-r>""<Esc>wq
This macro wraps the current word in double quotes by changing the word, inserting quotes around the original content, and moving to the next word.
@a (within macro @b)
Vim macros can call other macros, enabling modular macro composition.
:let @q =
Instead of recording a macro with q, you can assign any string directly to a named register using :let @{register} = 'keys'.
<C-r>:
Vim stores your last executed Ex command in the read-only : register.