VIM用粘贴缓冲区的内容替换字?

前端之家收集整理的这篇文章主要介绍了VIM用粘贴缓冲区的内容替换字?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我需要在一个文件中做一堆字替换,并希望使用vi命令,而不是一个EX命令,如:%s /// g。我知道这是在当前光标位置替换单词的典型方式:cw< text>< esc>但有没有办法做到这一点与未命名寄存器的内容作为替换文本,而不覆盖寄存器?
我想“粘贴”你的意思是未命名(yank / put / change / delete / substitute)注册,对不对? (因为这是那个将被覆盖的更改命令。)

寄存器通常通过键入“然后输入寄存器的名称(单个字符),例如”ay then“ap到yank into寄存器a,然后放入寄存器a的内容,同样适用于change命令,在这种情况下,你不希望使用change命令删除的文本到任何地方,你可以使用黑洞寄存器“_:”_cw。然后在插入模式下,你可以点击ctrl-R,然后跟注你想要的寄存器“)来放入该寄存器的内容

>“* – 选择寄存器(中间按钮粘贴)
>“ – 剪贴板寄存器(也可以通过ctrl-shift-v通过终端访问)
>“” – vim的默认(未命名)yank / put / change / delete / substitute寄存器。

简答:“_cw ^ R”

编辑:像其他人建议的,你当然可以使用一个不同的注册表(或任何),你的文本到默认寄存器。你不总是想到这一点,虽然,所以这是很好的做一个单一的更改命令,而不吹它。虽然它不是完全吹走。有编号的寄存器“0到”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 (this is Vi compatible). 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.

猜你在找的Bash相关文章