简体   繁体   中英

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 " .

For any other named register, you can just to Ctrl + R followed by the name of the register, like a or b .

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.

There are a couple of ways to do this.

  • Check :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
  • 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> . So you can say /<CR><CW> and that will get converted to /static given that your cursor is on the word static.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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