Vim:delete、delete whole line、yank、x使用的寄存器简明比较
Vim: Concise comparison of registers used for delete, delete whole line, yank, and x
我可以在 Vim 中找到许多对 "cutting" 和 "copying" 文本的狭义方面的部分解释,以及关于它如何工作的几个相互矛盾的想法,但我找不到一个简明扼要的概述。我正在寻找的是将它们全部放在一个地方的东西。我很确定我这里的内容是错误的并且有差距,但我想要一个完整的简明解释,如下所示:
key operation register used notes
y yank "" "0 and "1
x del 1 char "1 why doesn't xxxxxx fill all registers?
dd del line "" and "1
d[?] del [motion] "1
a p (put) with no specified register will put from register "1 (I think)
if an operation uses register "1 to store deleted/yanked text, then "1's
previous contents will be pushed to "2 and so on up to register "9 whose
previous content will disappear.
a "[alphanumeric] (quote followed by alphanumeric) before a d or y will
put the result into that register in addition to the registers it would
normally go in.
是的,这个问题被多次重复询问某个特定操作的详细信息。如果我错过了将文本放入删除或抽取寄存器的任何操作,我也想知道这些。
您应该可以在 :help "0
找到完整的解释。您的总结大部分是正确的,但是,您遗漏了 小删除 ,这些删除进入了一个特殊的 "-
寄存器。
key operation register used notes
y yank "" and "0
x del 1 char "" and "- small delete register
dd del line "" and "1
d[?] del [motion] "" and ("1 or "-) depending on the length of the text
a p (put) with no specified register will put from the default register ""
对于那些懒得输入 :help "0
的人,如 Ingo 的回答所示,这是我对帮助内容的简化版本:
- Unnamed register ""
Vim fills this register with text deleted with the "d", "c", "s", "x" commands or copied with the yank "y" 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. 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.
- Numbered registers "0 to "9
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, unless the command specified another register or 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. The "- register is used as well if the delete is within a line.
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.
- Small delete register "-
This register contains text from commands that delete less than one line,
except when the command specifies a register with ["x].
我可以在 Vim 中找到许多对 "cutting" 和 "copying" 文本的狭义方面的部分解释,以及关于它如何工作的几个相互矛盾的想法,但我找不到一个简明扼要的概述。我正在寻找的是将它们全部放在一个地方的东西。我很确定我这里的内容是错误的并且有差距,但我想要一个完整的简明解释,如下所示:
key operation register used notes
y yank "" "0 and "1
x del 1 char "1 why doesn't xxxxxx fill all registers?
dd del line "" and "1
d[?] del [motion] "1
a p (put) with no specified register will put from register "1 (I think)
if an operation uses register "1 to store deleted/yanked text, then "1's
previous contents will be pushed to "2 and so on up to register "9 whose
previous content will disappear.
a "[alphanumeric] (quote followed by alphanumeric) before a d or y will
put the result into that register in addition to the registers it would
normally go in.
是的,这个问题被多次重复询问某个特定操作的详细信息。如果我错过了将文本放入删除或抽取寄存器的任何操作,我也想知道这些。
您应该可以在 :help "0
找到完整的解释。您的总结大部分是正确的,但是,您遗漏了 小删除 ,这些删除进入了一个特殊的 "-
寄存器。
key operation register used notes
y yank "" and "0
x del 1 char "" and "- small delete register
dd del line "" and "1
d[?] del [motion] "" and ("1 or "-) depending on the length of the text
a p (put) with no specified register will put from the default register ""
对于那些懒得输入 :help "0
的人,如 Ingo 的回答所示,这是我对帮助内容的简化版本:
- Unnamed register ""
Vim fills this register with text deleted with the "d", "c", "s", "x" commands or copied with the yank "y" 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. 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.
- Numbered registers "0 to "9
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, unless the command specified another register or 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. The "- register is used as well if the delete is within a line.
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.
- Small delete register "-
This register contains text from commands that delete less than one line, except when the command specifies a register with ["x].