加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

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

发布时间:2020-12-15 16:58:44 所属栏目:安全 来源:网络整理
导读:我需要在一个文件中做一堆字替换,并希望使用vi命令,而不是一个EX命令,如:%s /// g。我知道这是在当前光标位置替换单词的典型方式:cw text esc但有没有办法做到这一点与未命名寄存器的内容作为替换文本,而不覆盖寄存器? 我想“粘贴”你的意思是未命名
我需要在一个文件中做一堆字替换,并希望使用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.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读