gvim中.怎么样将寄存器的内容查找和替换

Vim、Emacs配置和使用
回复
fjlinhua
帖子: 8
注册时间: 2012-05-26 7:02

gvim中.怎么样将寄存器的内容查找和替换

#1

帖子 fjlinhua » 2012-05-26 7:10

例如说一段内容:
if("VOX".equals(&PARAM2)){
String vObjectId=&URGEOBJECT.getSObjectId();
OutputParamUtil opuCallType=Invoke("checkCallType",new String[]
{&AREAID,&CALLER_NBR,vObjectId});
if(!opuCallType.isSuccess()){
log.error("调用服务checkCallType失败,,这次不呼出");
callFlag=19;
return ;
}

将第一行的VOX关键字,存储在寄存器a中。,我想在command模式下,直接将寄存器a的内容那出来当做关键字
进行查找,或者作为替换的关键字,进行替换,需要怎么处理
头像
lilydjwg
论坛版主
帖子: 4258
注册时间: 2009-04-11 23:46
系统: Arch Linux
联系:

Re: gvim中.怎么样将寄存器的内容查找和替换

#2

帖子 lilydjwg » 2012-05-26 13:31

command模式是什么东西?

代码: 全选

:h c_ctrl-r
这个?
Sharp_0xD
帖子: 1
注册时间: 2012-05-27 11:35

Re: gvim中.怎么样将寄存器的内容查找和替换

#3

帖子 Sharp_0xD » 2012-05-27 11:38

:em11
这个容易啊,gvim?是不是windows下的,我的是的。按ctrl+R再输入寄存器名字就可以把寄存器中的内容插入进来了 ,插入模式也是一样的方法。
fjlinhua
帖子: 8
注册时间: 2012-05-26 7:02

Re: gvim中.怎么样将寄存器的内容查找和替换

#4

帖子 fjlinhua » 2012-05-27 15:57

谢谢,这个方法不错。
fjlinhua
帖子: 8
注册时间: 2012-05-26 7:02

Re: gvim中.怎么样将寄存器的内容查找和替换

#5

帖子 fjlinhua » 2012-06-08 9:37

从网络上搜了集中方法:

代码: 全选

:%s/foo/<c-r>a/g
将foo用寄存器a的值来替换.
Replace each occurrence of 'foo' with the contents of register 'a'.
<c-r>a means that you press Ctrl-R then a.
The contents of register 'a' will be inserted as though you typed it.

代码: 全选

:%s/foo/\=@a/g 
将foo用寄存器a的值来替换.
Replace each occurrence of 'foo' with the contents of register 'a'.
\=@a is a reference to register 'a'.
The contents of register 'a' is not shown in the command. This is useful if the register contains many lines of text.

代码: 全选

:%s/<c-r>*/bar/g 
根据系统剪贴板的内容查找,并且用bar来替换.
Replace all occurrences of the text in the system clipboard (in the * register) with 'bar' (see next example if multiline).
On some systems, selecting text (in Vim or another application) is all that is required to place that text in the * register.

代码: 全选

:%s/<c-r>a/bar/g
Replace all occurrences of the text in register 'a' with 'bar'.
<c-r>a means that you press Ctrl-R then a. The contents of register 'a' will be inserted as though you typed it.
Any newlines in register 'a' are inserted as ^M and are not found.
The search works if each ^M is manually replaced with '\n' (two characters: backslash, 'n').
This replacement can be performed while you type the command:
回复