command, regardless of whether or not a specific
register was used (e.g. "xdd). This is like the unnamed register is pointing
to the last used register. Thus when appending using an uppercase register
name, the unnamed register contains the same text as the named register.
An exception is the '_' register: "_dd does not store the deleted text in any
register.
Vim uses the contents of the unnamed register for any put command (p or P)
which does not specify a register. Additionally you can access it with the
name '"'. This means you have to type two double quotes. Writing to the ""
register writes to register "0.
2. Numbered registers "0 to "9 *quote_number* *quote0* *quote1*
*quote2* *quote3* *quote4* *quote9*
Vim fills these registers with text from yank and delete commands.
Numbered register 0 contains the text from the most recent yank command,
unless the command specified another register with ["x].
Numbered register 1 contains the text deleted by the most recent delete or
change command (even when the command specified another register), unless the
text is less than one line (the small delete register is used then). An
exception is made for the delete operator with these movement commands: |%|,
|(|, |)|, |`|, |/|, |?|, |n|, |N|, |{| and |}|.
Register "1 is always used then (this is Vi compatible). The "- register is
used as well if the delete is within a line. Note that these characters may be
mapped. E.g. |%| is mapped by the matchit plugin.
With each successive deletion or change, Vim shifts the previous contents
of register 1 into register 2, 2 into 3, and so forth, losing the previous
contents of register 9.
*yankring*
To also store yanks (not only deletions) in registers 1-9, try this: >lua
-- Yank-ring: store yanked text in registers 1-9.
vim.api.nvim_create_autocmd('TextYankPost', {
callback = function()
if vim.v.event.operator == 'y' then
for i = 9, 1, -1 do -- Shift all numbered registers.
vim.fn.setreg(tostring(i), vim.fn.getreg(tostring(i - 1)))
end
end
end,
})
3. Small delete register "- *quote_-* *quote-*
This register contains text from commands that delete less than one line,
except when the command specifies a register with ["x].
4. Named registers "a to "z or "A to "Z *quote_alpha* *quotea*
Vim fills these registers only when you say so. Specify them as lowercase
letters to replace their previous contents or as uppercase letters to append
to their previous contents. When the '>' flag is present in 'cpoptions' then
a line break is inserted before the appended text.
5. Read-only registers ":, ". and "%
These are '%', ':' and '.'. You can use them only with the "p", "P",
and ":put" commands and with CTRL-R.
*quote_.* *quote.* *E29*
". Contains the last inserted text (the same as what is inserted
with the insert mode commands CTRL-A and CTRL-@). Note: this
doesn't work with CTRL-R on the command-line. It works a bit
differently, like inserting the text instead of putting it
('textwidth' and other options affect what is inserted).
*quote_%* *quote%*
"% Contains the name of the current file.
*quote_:* *quote:* *E30*
": Contains the most recent executed command-line. Example: Use
"@:" to repeat the previous command-line command.
The command-line is only stored in this register when at least
one character of it was typed. Thus it remains unchanged if
the command was completely from a mapping.
*quote_#* *quote#*
6. Alternate file register "#
Contains the name of the alternate file for the current window. It will
change how the |CTRL-^| command works.
This register is writable, mainly to allow for restoring it after a plugin has
changed it. It accepts buffer number: >
let altbuf = bufnr(@#)
...
let @# = altbuf
It will give error |E86| if you pass buffer number and this buffer does not
exist.
It can also accept a match with an existing buffer