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.
"# register
The # register contains the name of the alternate file — the previously edited file in the current window.
:let @b = @a
The :let @b = @a command copies the contents of register a into register b.
"adiw
The "adiw command deletes the inner word under the cursor and stores it in register a.
"+y and "+p
The "+ register is linked to the system clipboard.
"/ register
The / register contains the most recent search pattern.
"1p through "9p
Registers 1-9 contain the last 9 deletions or changes that are at least one line long.
".
The .
":
The : register contains the last Ex command that was executed.
"=2+3<CR>p
The expression register = evaluates a Vimscript expression and stores the result.
:let @a = ""
The :let @{register} = "" command empties a register.
"ap, edit, "add
Since macros are stored in registers, you can paste the register content into the buffer, edit it, and yank it back.
<C-v>jj"ay then "ap
How it works Vim registers remember not just the text content but also the type of selection that was used to yank it: characterwise, linewise, or blockwise.
:call setreg('a', @a . 'text', 'l')
How it works Vim provides two functions for advanced register manipulation: setreg() and getreg().
:%s/pattern/\=@a/g
How it works In Vim's substitute command, the replacement string can be a Vimscript expression when prefixed with \=.
:@a
How it works The command :@a executes the contents of register a as an Ex command.
"*p vs "+p
How it works Vim has two system clipboard registers that interact with the operating system: " -- the selection register (PRIMARY selection on Linux/X11, clipbo
/<C-r>0
How it works After yanking text, you can use it directly as a search pattern by inserting the yank register contents into the search prompt.
:<C-r>a
How it works While typing an Ex command on the command line (after pressing :), you can insert the contents of any register by pressing Ctrl-R followed by the r
"add
How it works When you delete text in Vim with commands like dd, dw, or x, the deleted text goes into the unnamed register and the numbered registers (1-9).
"ayy "byy "cyy
How it works Vim provides 26 named registers (a through z) that you can use as independent clipboards.