如何使用vim寄存器?

时间:2022-06-01 11:48:20

I only know of one instance using registers is via CtrlR* whereby I paste text from a clipboard.

我只知道一个使用寄存器的实例是通过ctrl lr *粘贴剪贴板中的文本。

What are other uses of registers? How to use them?

寄存器的其他用途是什么?如何使用它们?

Everything you know about VI registers (let's focus on vi 7.2) -- share with us.

您所了解的VI寄存器(让我们关注VI 7.2)——与我们共享。

15 个解决方案

#1


1006  

Registers in Vim let you run actions or commands on text stored within them. To access a register, you type "a before a command, where a is the name of a register. If you want to copy the current line into register k, you can type

在Vim中的寄存器允许您在其中存储的文本上运行操作或命令。要访问寄存器,您需要在命令之前输入“a”,其中a是寄存器的名称。如果要将当前行复制到寄存器k,可以输入

"kyy

“kyy

Or you can append to a register by using a capital letter

或者你也可以用大写字母来附加注册表

"Kyy

“Kyy

You can then move through the document and paste it elsewhere using

然后,您可以移动文档并将其粘贴到其他地方

"kp

“kp

To paste from system clipboard on Linux

在Linux上粘贴系统剪贴板。

"+p

“+ p

To paste from system clipboard on Windows (or from "mouse highlight" clipboard on Linux)

从Windows上的系统剪贴板粘贴(或从Linux上的“鼠标高亮显示”剪贴板粘贴)

"*p

“* p

To access all currently defined registers type

访问所有当前定义的寄存器类型

:reg

:注册

#2


697  

I was pleased when I discovered the 0 register. If you yank text without assigning it to a particular register, then it will be assigned to the 0 register, as well as being saved in the default " register. The difference between the 0 and " registers is that 0 is only populated with yanked text, whereas the default register is also populated with text deleted using d/D/x/X/c/C/s/S commands.

当我发现0寄存器时,我很高兴。如果您删除文本而不将其分配给特定的寄存器,那么它将被分配给0寄存器,并保存在默认的“寄存器”中。0和“register”之间的不同之处在于,0只使用被删除的文本填充,而默认寄存器也使用d/ d/ x/ x/ x/ c/ c/ s/ s命令填充被删除的文本。

I find this useful when I want to copy some text, delete something and replace it with the copied text. The following steps illustrate an example:

当我想要复制一些文本、删除一些内容并将其替换为复制的文本时,我发现这很有用。以下步骤举例说明:

  • Yank the text you want to copy with y[motion] - this text is saved in " and 0 registers
  • 把你想要拷贝的文本拖拽到y[运动]中——这个文本被保存在"和0寄存器中
  • Delete the text you want to replace with d[motion] - this text is saved in " register
  • 删除你想要用d[motion]替换的文本——该文本保存在“register”中
  • Paste the yanked text with "0p
  • 用“0p”粘贴删除的文本

where " is the command to use a register for the next command.

“where”是为下一个命令使用寄存器的命令。

On the final step, if you were to paste from the default register (with p), it would use the text that you had just deleted (probably not what you intended).

在最后一步中,如果您要从默认寄存器(用p)粘贴,它将使用您刚才删除的文本(可能不是您想要的)。

Note that p or P pastes from the default register. The longhand equivalent would be ""p (or ""P) and "0 holds the last yank, "1holds the last delete or change.

注意,p或p从默认寄存器粘贴。longhand的等价词是“p”(或“p”)和“0表示最后一次扬音”,1表示最后一次删除或更改。

For more info see :help registers.

有关更多信息,请参见:帮助注册。

#3


297  

One of my favorite parts about registers is using them as macros!

关于寄存器,我最喜欢的部分之一是将它们用作宏!

Let's say you are dealing with a tab-delimited value file as such:

假设您正在处理一个以表分隔的值文件:

ID  Df  %Dev    Lambda1   0   0.000000    0.3136822   1   0.023113    0.3043323   1   0.044869    0.2952614   1   0.065347    0.2864605   1   0.084623    0.2779226   1   0.102767    0.2696387   1   0.119845    0.261601

Now you decide that you need to add a percentage sign at the end of the %Dev field (starting from 2nd line). We'll make a simple macro in the (arbitrarily selected) m register as follows:

现在您决定需要在%Dev字段的末尾(从第2行开始)添加一个百分号。我们将在(任意选择的)m寄存器中创建一个简单的宏,如下所示:

  1. Press: qm: To start recording macro under m register.

    按:qm:开始在m寄存器下录制宏。

  2. EE: Go to the end of the 3rd column.

    EE:到第三列的末尾。

  3. a: Insert mode to append to the end of this column.

    a:将模式插入到本专栏末尾。

  4. %: Type the percent sign we want to add.

    %:键入要添加的百分号。

  5. <ESC>: Get back into command mode.

    :回到命令模式。

  6. j0: Go to beginning of next line.

    到下一行的开始。

  7. q: Stop recording macro

    问:停止录制宏

We can now just type @m to run this macro on the current line. Furthermore, we can type @@ to repeat, or 100@m to do this 100 times! Life's looking pretty good.

我们现在只需输入@m就可以在当前行上运行这个宏。此外,我们可以输入@来重复,或者输入100@m来重复100次!生活的很好。

At this point you should be saying, "BUT WAIT, WHAT THE HECK DOES THIS HAVE TO DO WITH REGISTERS?"

这时你应该说,“但是等等,这和寄存器有什么关系?”

Excellent point. Let's investigate what is in the contents of the m register by typing "mp. We then get the following:

优秀的点。让我们通过输入“mp”来研究m寄存器的内容。然后我们得到以下信息:

EEa%<ESC>j0

At first this looks like you accidentally opened a binary file in notepad, but upon second glance, it's the exact sequence of characters in our macro!

乍一看,这看起来像是你不小心在记事本中打开了一个二进制文件,但再看一眼,它就是我们的宏中的字符序列!

You are a curious person, so let's do something interesting and edit this line of text to insert a ! instead of boring old %.

您是一个好奇的人,所以让我们做一些有趣的事情,编辑这行文本插入一个!而不是无聊的老%。

EEa!<ESC>j0

Then let's yank this into the n register by typing B"nyE. Then, just for kicks, let's run the n macro on a line of our data using @n....

然后我们输入B ' nyE,把它拉进n寄存器。然后,只是为了好玩,让我们运行n宏一行数据使用@n ....

OMG, IT ADDED A !

天啊,它加了个A !

Essentially, running a macro is like pressing the exact sequence of keys in that macro's register. If that isn't a cool register trick, I'll eat my hat.

本质上,运行宏就像按下宏寄存器中键的确切顺序。如果这不是一个很酷的注册技巧,我就把我的帽子给吃了。

#4


93  

Other useful registers:

其他有用的注册:

"* or "+ - the contents of the system clipboard

"*或"+ -系统剪贴板的内容。

"/ - last search command

-最后的搜索命令

": - last command.

”:——最后一个命令。

Note with vim macros, you can edit them, since they are just a list of the keystrokes used when recording the macro. So you can write to a text file the macro (using "ap to write macro a) and edit them, and load them into a register with "ay$. Nice way of storing useful macros.

注意使用vim宏,您可以编辑它们,因为它们只是记录宏时使用的按键的列表。因此,您可以将宏写入文本文件(使用“ap来编写宏a”)并编辑它们,并将它们加载到一个带有“ay$”的寄存器中。存储有用宏的好方法。

#5


65  

The black hole register _ is the /dev/null of registers.

黑洞寄存器_是寄存器的/dev/null。

I use it in my vimrc to allow deleting single characters without updating the default register:

我在vimrc中使用它可以删除单个字符而不更新默认寄存器:

noremap x "_x

and to paste in visual mode without updating the default register:

在视觉模式下粘贴而不更新默认寄存器:

vnoremap p "_dP

#6


45  

If you ever want to paste the contents of the register in an ex-mode command, hit <C-r><registerletter>.

如果您想要在ex模式命令中粘贴寄存器的内容,请单击

Why would you use this? I wanted to do a search and replace for a longish string, so I selected it in visual mode, started typing out the search/replace expression :%s/[PASTE YANKED PHRASE]//g and went on my day.

你为什么要用这个?我想搜索并替换一个较长的字符串,所以我选择了视觉模式,开始输入搜索/替换表达式:%s/[粘贴删除的短语]// /g,然后开始我的一天。

If you only want to paste a single word in ex mode, can make sure the cursor is on it before entering ex mode, and then hit <C-r><C-w> when in ex mode to paste the word.

如果你只想在ex模式下粘贴一个单词,可以在进入ex模式前确保光标在上面,在ex模式下点击 粘贴单词。

#7


39  

I think the secret guru register is the expression = register. It can be used for creative mappings.

我认为秘密上师寄存器是表达式=寄存器。它可以用于创造性映射。

:inoremap  \d The current date <c-r>=system("date")<cr>

You can use it in conjunction with your system as above or get responses from custom VimL functions etc.

您可以将它与您的系统结合使用,或者从自定义VimL函数中获得响应,等等。

or just ad hoc stuff like

或者只是一些特别的事情

<c-r>=35+7<cr>

#8


31  

A cool trick is to use "1p to paste the last delete/change (, and then use . to repeatedly to paste the subsequent deletes. In other words, "1p... is basically equivalent to "1p"2p"3p"4p.

一个很酷的技巧是使用“1p粘贴最后一个删除/更改(,然后使用)。重复粘贴后续删除。换句话说,“1 p…基本上相当于“1p”2p“3p”4p。

You can use this to reverse-order a handful of lines:dddddddddd"1p....

您可以使用此倒序少数行:dddddddddd“1 p ....

#9


16  

  • q5 records edits into register 5 (next q stops recording)
  • q5记录编辑为寄存器5(下一个q停止记录)
  • :reg show all registers and any contents in them
  • :reg显示所有寄存器和其中的任何内容
  • @5 execute register 5 macro (recorded edits)
  • @5执行寄存器5宏(记录编辑)

#10


16  

From vim's help page:

从vim的帮助页面:

CTRL-R {0-9a-z"%#:-=.}                  *c_CTRL-R* *c_<C-R>*        Insert the contents of a numbered or named register.  Between        typing CTRL-R and the second character '"' will be displayed        <...snip...>        Special registers:            '"' the unnamed register, containing the text of                the last delete or yank            '%' the current file name            '#' the alternate file name            '*' the clipboard contents (X11: primary selection)            '+' the clipboard contents            '/' the last search pattern            ':' the last command-line            '-' the last small (less than a line) delete            '.' the last inserted text                            *c_CTRL-R_=*            '=' the expression register: you are prompted to                enter an expression (see |expression|)                (doesn't work at the expression prompt; some                things such as changing the buffer or current                window are not allowed to avoid side effects)                When the result is a |List| the items are used                as lines.  They can have line breaks inside                too.                When the result is a Float it's automatically                converted to a String.        See |registers| about registers.  {not in Vi}        <...snip...>

#11


14  

I use the default register to grep for text in my vim window without having to reach for the mouse.

我在vim窗口中使用默认的grep寄存器来读取文本,而不需要访问鼠标。

  1. yank text
  2. 把文本
  3. :!grep "<CTRL-R>0"<CR>
  4. :!grep”< CTRL-R > 0 < CR >

#12


9  

Use registers in commands with @. E.g.:

在带有@的命令中使用寄存器。例如:

echo @aecho @0echo @+

Set them in command:

让他们在命令:

let @a = 'abc'

Now "ap will paste abc.

现在,ap将粘贴abc。

#13


8  

A big source of confusion is the default register ". It is important to know the way it works. It is much better if the default register is avoided most of the times. The explanation from the Vim documentation:

一个很大的混淆来源是默认寄存器。知道它的工作方式很重要。如果大多数时候都避免使用默认寄存器,那就更好了。Vim文件的解释:

Vim fills this register with text deleted with the "d", "c", "s", "x" commandsor copied with the yank "y" command, regardless of whether or not a specificregister was used (e.g.  "xdd).  This is like the unnamed register is pointingto the last used register.

So the default register is actually a pointer to the last used register. When you delete, or yank something this register is going to point to other registers. You can test that by checking the registers. There is always another register that is exactly the same as the default register: the yank register ("0) , the first delete register("1) , small delete register("-) or any other register that was used to delete or yank.

所以默认寄存器实际上是一个指向最后一个寄存器的指针。当你删除或删除某些内容时,这个寄存器会指向其他寄存器。您可以通过检查寄存器来测试它。总是有另一个寄存器与默认寄存器完全相同:扬库寄存器(“0”)、第一个删除寄存器(“1”)、小删除寄存器(“-”)或任何其他用于删除或删除的寄存器。

The only exception is the black hole register. Vim doc says:

唯一的例外是黑洞寄存器。Vim医生说:

An exception is the '_' register: "_dd does not store the deleted text in anyregister.

Usually you are much better off by using directly: "0, "- and "1-"9 default registers or named registers.

通常,通过直接使用:“0”、“-”和“1-”9默认寄存器或命名寄存器,您的情况会好得多。

#14


2  

One overlooked register is the '.' dot register which contains the last inserted text no matter how it was inserted eg ct] (change till ]). Then you realise you need to insert it elsewhere but can't use the dot repeat method.

一个被忽视的寄存器是。“点寄存器”包含最后插入的文本,无论它是如何插入的(如ct)[(改为till])。然后您会意识到您需要将它插入到其他地方,但不能使用点重复方法。

 :reg . :%s/fred/<C-R>./

#15


1  

My favorite register is the ':' register. Running @: in Normal mode allows me to repeat the previously ran ex command.

我最喜欢的寄存器是:寄存器。运行@:在正常模式下允许我重复先前运行的ex命令。

#1


1006  

Registers in Vim let you run actions or commands on text stored within them. To access a register, you type "a before a command, where a is the name of a register. If you want to copy the current line into register k, you can type

在Vim中的寄存器允许您在其中存储的文本上运行操作或命令。要访问寄存器,您需要在命令之前输入“a”,其中a是寄存器的名称。如果要将当前行复制到寄存器k,可以输入

"kyy

“kyy

Or you can append to a register by using a capital letter

或者你也可以用大写字母来附加注册表

"Kyy

“Kyy

You can then move through the document and paste it elsewhere using

然后,您可以移动文档并将其粘贴到其他地方

"kp

“kp

To paste from system clipboard on Linux

在Linux上粘贴系统剪贴板。

"+p

“+ p

To paste from system clipboard on Windows (or from "mouse highlight" clipboard on Linux)

从Windows上的系统剪贴板粘贴(或从Linux上的“鼠标高亮显示”剪贴板粘贴)

"*p

“* p

To access all currently defined registers type

访问所有当前定义的寄存器类型

:reg

:注册

#2


697  

I was pleased when I discovered the 0 register. If you yank text without assigning it to a particular register, then it will be assigned to the 0 register, as well as being saved in the default " register. The difference between the 0 and " registers is that 0 is only populated with yanked text, whereas the default register is also populated with text deleted using d/D/x/X/c/C/s/S commands.

当我发现0寄存器时,我很高兴。如果您删除文本而不将其分配给特定的寄存器,那么它将被分配给0寄存器,并保存在默认的“寄存器”中。0和“register”之间的不同之处在于,0只使用被删除的文本填充,而默认寄存器也使用d/ d/ x/ x/ x/ c/ c/ s/ s命令填充被删除的文本。

I find this useful when I want to copy some text, delete something and replace it with the copied text. The following steps illustrate an example:

当我想要复制一些文本、删除一些内容并将其替换为复制的文本时,我发现这很有用。以下步骤举例说明:

  • Yank the text you want to copy with y[motion] - this text is saved in " and 0 registers
  • 把你想要拷贝的文本拖拽到y[运动]中——这个文本被保存在"和0寄存器中
  • Delete the text you want to replace with d[motion] - this text is saved in " register
  • 删除你想要用d[motion]替换的文本——该文本保存在“register”中
  • Paste the yanked text with "0p
  • 用“0p”粘贴删除的文本

where " is the command to use a register for the next command.

“where”是为下一个命令使用寄存器的命令。

On the final step, if you were to paste from the default register (with p), it would use the text that you had just deleted (probably not what you intended).

在最后一步中,如果您要从默认寄存器(用p)粘贴,它将使用您刚才删除的文本(可能不是您想要的)。

Note that p or P pastes from the default register. The longhand equivalent would be ""p (or ""P) and "0 holds the last yank, "1holds the last delete or change.

注意,p或p从默认寄存器粘贴。longhand的等价词是“p”(或“p”)和“0表示最后一次扬音”,1表示最后一次删除或更改。

For more info see :help registers.

有关更多信息,请参见:帮助注册。

#3


297  

One of my favorite parts about registers is using them as macros!

关于寄存器,我最喜欢的部分之一是将它们用作宏!

Let's say you are dealing with a tab-delimited value file as such:

假设您正在处理一个以表分隔的值文件:

ID  Df  %Dev    Lambda1   0   0.000000    0.3136822   1   0.023113    0.3043323   1   0.044869    0.2952614   1   0.065347    0.2864605   1   0.084623    0.2779226   1   0.102767    0.2696387   1   0.119845    0.261601

Now you decide that you need to add a percentage sign at the end of the %Dev field (starting from 2nd line). We'll make a simple macro in the (arbitrarily selected) m register as follows:

现在您决定需要在%Dev字段的末尾(从第2行开始)添加一个百分号。我们将在(任意选择的)m寄存器中创建一个简单的宏,如下所示:

  1. Press: qm: To start recording macro under m register.

    按:qm:开始在m寄存器下录制宏。

  2. EE: Go to the end of the 3rd column.

    EE:到第三列的末尾。

  3. a: Insert mode to append to the end of this column.

    a:将模式插入到本专栏末尾。

  4. %: Type the percent sign we want to add.

    %:键入要添加的百分号。

  5. <ESC>: Get back into command mode.

    :回到命令模式。

  6. j0: Go to beginning of next line.

    到下一行的开始。

  7. q: Stop recording macro

    问:停止录制宏

We can now just type @m to run this macro on the current line. Furthermore, we can type @@ to repeat, or 100@m to do this 100 times! Life's looking pretty good.

我们现在只需输入@m就可以在当前行上运行这个宏。此外,我们可以输入@来重复,或者输入100@m来重复100次!生活的很好。

At this point you should be saying, "BUT WAIT, WHAT THE HECK DOES THIS HAVE TO DO WITH REGISTERS?"

这时你应该说,“但是等等,这和寄存器有什么关系?”

Excellent point. Let's investigate what is in the contents of the m register by typing "mp. We then get the following:

优秀的点。让我们通过输入“mp”来研究m寄存器的内容。然后我们得到以下信息:

EEa%<ESC>j0

At first this looks like you accidentally opened a binary file in notepad, but upon second glance, it's the exact sequence of characters in our macro!

乍一看,这看起来像是你不小心在记事本中打开了一个二进制文件,但再看一眼,它就是我们的宏中的字符序列!

You are a curious person, so let's do something interesting and edit this line of text to insert a ! instead of boring old %.

您是一个好奇的人,所以让我们做一些有趣的事情,编辑这行文本插入一个!而不是无聊的老%。

EEa!<ESC>j0

Then let's yank this into the n register by typing B"nyE. Then, just for kicks, let's run the n macro on a line of our data using @n....

然后我们输入B ' nyE,把它拉进n寄存器。然后,只是为了好玩,让我们运行n宏一行数据使用@n ....

OMG, IT ADDED A !

天啊,它加了个A !

Essentially, running a macro is like pressing the exact sequence of keys in that macro's register. If that isn't a cool register trick, I'll eat my hat.

本质上,运行宏就像按下宏寄存器中键的确切顺序。如果这不是一个很酷的注册技巧,我就把我的帽子给吃了。

#4


93  

Other useful registers:

其他有用的注册:

"* or "+ - the contents of the system clipboard

"*或"+ -系统剪贴板的内容。

"/ - last search command

-最后的搜索命令

": - last command.

”:——最后一个命令。

Note with vim macros, you can edit them, since they are just a list of the keystrokes used when recording the macro. So you can write to a text file the macro (using "ap to write macro a) and edit them, and load them into a register with "ay$. Nice way of storing useful macros.

注意使用vim宏,您可以编辑它们,因为它们只是记录宏时使用的按键的列表。因此,您可以将宏写入文本文件(使用“ap来编写宏a”)并编辑它们,并将它们加载到一个带有“ay$”的寄存器中。存储有用宏的好方法。

#5


65  

The black hole register _ is the /dev/null of registers.

黑洞寄存器_是寄存器的/dev/null。

I use it in my vimrc to allow deleting single characters without updating the default register:

我在vimrc中使用它可以删除单个字符而不更新默认寄存器:

noremap x "_x

and to paste in visual mode without updating the default register:

在视觉模式下粘贴而不更新默认寄存器:

vnoremap p "_dP

#6


45  

If you ever want to paste the contents of the register in an ex-mode command, hit <C-r><registerletter>.

如果您想要在ex模式命令中粘贴寄存器的内容,请单击

Why would you use this? I wanted to do a search and replace for a longish string, so I selected it in visual mode, started typing out the search/replace expression :%s/[PASTE YANKED PHRASE]//g and went on my day.

你为什么要用这个?我想搜索并替换一个较长的字符串,所以我选择了视觉模式,开始输入搜索/替换表达式:%s/[粘贴删除的短语]// /g,然后开始我的一天。

If you only want to paste a single word in ex mode, can make sure the cursor is on it before entering ex mode, and then hit <C-r><C-w> when in ex mode to paste the word.

如果你只想在ex模式下粘贴一个单词,可以在进入ex模式前确保光标在上面,在ex模式下点击 粘贴单词。

#7


39  

I think the secret guru register is the expression = register. It can be used for creative mappings.

我认为秘密上师寄存器是表达式=寄存器。它可以用于创造性映射。

:inoremap  \d The current date <c-r>=system("date")<cr>

You can use it in conjunction with your system as above or get responses from custom VimL functions etc.

您可以将它与您的系统结合使用,或者从自定义VimL函数中获得响应,等等。

or just ad hoc stuff like

或者只是一些特别的事情

<c-r>=35+7<cr>

#8


31  

A cool trick is to use "1p to paste the last delete/change (, and then use . to repeatedly to paste the subsequent deletes. In other words, "1p... is basically equivalent to "1p"2p"3p"4p.

一个很酷的技巧是使用“1p粘贴最后一个删除/更改(,然后使用)。重复粘贴后续删除。换句话说,“1 p…基本上相当于“1p”2p“3p”4p。

You can use this to reverse-order a handful of lines:dddddddddd"1p....

您可以使用此倒序少数行:dddddddddd“1 p ....

#9


16  

  • q5 records edits into register 5 (next q stops recording)
  • q5记录编辑为寄存器5(下一个q停止记录)
  • :reg show all registers and any contents in them
  • :reg显示所有寄存器和其中的任何内容
  • @5 execute register 5 macro (recorded edits)
  • @5执行寄存器5宏(记录编辑)

#10


16  

From vim's help page:

从vim的帮助页面:

CTRL-R {0-9a-z"%#:-=.}                  *c_CTRL-R* *c_<C-R>*        Insert the contents of a numbered or named register.  Between        typing CTRL-R and the second character '"' will be displayed        <...snip...>        Special registers:            '"' the unnamed register, containing the text of                the last delete or yank            '%' the current file name            '#' the alternate file name            '*' the clipboard contents (X11: primary selection)            '+' the clipboard contents            '/' the last search pattern            ':' the last command-line            '-' the last small (less than a line) delete            '.' the last inserted text                            *c_CTRL-R_=*            '=' the expression register: you are prompted to                enter an expression (see |expression|)                (doesn't work at the expression prompt; some                things such as changing the buffer or current                window are not allowed to avoid side effects)                When the result is a |List| the items are used                as lines.  They can have line breaks inside                too.                When the result is a Float it's automatically                converted to a String.        See |registers| about registers.  {not in Vi}        <...snip...>

#11


14  

I use the default register to grep for text in my vim window without having to reach for the mouse.

我在vim窗口中使用默认的grep寄存器来读取文本,而不需要访问鼠标。

  1. yank text
  2. 把文本
  3. :!grep "<CTRL-R>0"<CR>
  4. :!grep”< CTRL-R > 0 < CR >

#12


9  

Use registers in commands with @. E.g.:

在带有@的命令中使用寄存器。例如:

echo @aecho @0echo @+

Set them in command:

让他们在命令:

let @a = 'abc'

Now "ap will paste abc.

现在,ap将粘贴abc。

#13


8  

A big source of confusion is the default register ". It is important to know the way it works. It is much better if the default register is avoided most of the times. The explanation from the Vim documentation:

一个很大的混淆来源是默认寄存器。知道它的工作方式很重要。如果大多数时候都避免使用默认寄存器,那就更好了。Vim文件的解释:

Vim fills this register with text deleted with the "d", "c", "s", "x" commandsor copied with the yank "y" command, regardless of whether or not a specificregister was used (e.g.  "xdd).  This is like the unnamed register is pointingto the last used register.

So the default register is actually a pointer to the last used register. When you delete, or yank something this register is going to point to other registers. You can test that by checking the registers. There is always another register that is exactly the same as the default register: the yank register ("0) , the first delete register("1) , small delete register("-) or any other register that was used to delete or yank.

所以默认寄存器实际上是一个指向最后一个寄存器的指针。当你删除或删除某些内容时,这个寄存器会指向其他寄存器。您可以通过检查寄存器来测试它。总是有另一个寄存器与默认寄存器完全相同:扬库寄存器(“0”)、第一个删除寄存器(“1”)、小删除寄存器(“-”)或任何其他用于删除或删除的寄存器。

The only exception is the black hole register. Vim doc says:

唯一的例外是黑洞寄存器。Vim医生说:

An exception is the '_' register: "_dd does not store the deleted text in anyregister.

Usually you are much better off by using directly: "0, "- and "1-"9 default registers or named registers.

通常,通过直接使用:“0”、“-”和“1-”9默认寄存器或命名寄存器,您的情况会好得多。

#14


2  

One overlooked register is the '.' dot register which contains the last inserted text no matter how it was inserted eg ct] (change till ]). Then you realise you need to insert it elsewhere but can't use the dot repeat method.

一个被忽视的寄存器是。“点寄存器”包含最后插入的文本,无论它是如何插入的(如ct)[(改为till])。然后您会意识到您需要将它插入到其他地方,但不能使用点重复方法。

 :reg . :%s/fred/<C-R>./

#15


1  

My favorite register is the ':' register. Running @: in Normal mode allows me to repeat the previously ran ex command.

我最喜欢的寄存器是:寄存器。运行@:在正常模式下允许我重复先前运行的ex命令。