简体   繁体   English

如何在vim的命令行模式下粘贴文本?

[英]How to paste the text in command-line mode in vim?

I have copied a word to search from the file. 我已经复制了一个单词以从文件中搜索。

Is there a command to paste that word in command-line mode. 是否有命令以命令行方式粘贴该单词。

For eg. 例如。 I have copied the word 'static' from the code below in default register and I want to paste that in command-line mode, as below 我已经从下面的代码中的默认寄存器中复制了“静态”一词,我想在命令行模式下粘贴它,如下所示

/static /静态的

1275 static const struct of_device_id omap_mcspi_of_match[] = {
1276         {
1277                 .compatible = "ti,omap2-mcspi",
1278                 .data = &omap2_pdata,
1279         },
1280         {
1281                 .compatible = "ti,omap4-mcspi",
1282                 .data = &omap4_pdata,
1283         },
1284         { },
1285 };

While in either command mode or in search mode, type Ctrl + R " to paste from the default register. That is, type Ctrl + R , release it and then type " . 在命令模式或搜索模式下,键入Ctrl + R 从默认寄存器中粘贴。即,键入Ctrl + R ,释放它,然后键入

For any other named register, you can just to Ctrl + R followed by the name of the register, like a or b . 对于任何其他命名的寄存器,只需按Ctrl + R,后跟寄存器的名称即可,例如ab

Alternately, if you enter search mode using the command q/ instead of just / , you can simply use p to paste, the same way you would in a normal buffer. 或者,如果您使用以下命令输入搜索模式q/而不仅仅是/ ,你可以简单地使用p粘贴,你在一个正常的缓冲会以同样的方式。

There are a couple of ways to do this. 有两种方法可以做到这一点。

  • Check :h c_^r . 检查:h c_^r On the command-line you can say /<CR>" to copy the contents of the default register " and it will get converted to /static 在命令行上,您可以说/<CR>"复制默认寄存器的内容”,它将转换为/static
  • Alternately, a more convenient way (in most cases) is to use :h c_^r^w to copy the current word under the cursor denoted by <cword> . 或者,更方便的方法(在大多数情况下)是使用:h c_^r^w<cword>表示的光标下复制当前单词。 So you can say /<CR><CW> and that will get converted to /static given that your cursor is on the word static. 因此,您可以说/<CR><CW> ,并且将光标转换为/static将其转换为/static static。

只需将光标置于static就可以打*呢?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM