在Ultraedit中用宏实现将选中的代码设置为注释

<script type="text/javascript"> </script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script>
<script type="text/javascript"> </script><script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script>
面是对代码块设成注释的宏语句,使用前需要先选中希望注释的代码块,选中的首尾位置可以在首位行的任意位置,这里用的是"/*"和"*/",本来希望做成对每一行加"//",这样就像VS.NET了,可惜UE宏不支持变量,所以没想到实现的好办法。

InsertMode
ColumnModeOff
HexOff
UnixReOff
IfSel
StartSelect
Key END
Cut
Key HOME
IfColNum 1
Key END
EndIf
"/* "
TimeDate
"
"
Key END
Paste
Key END
"
"
TimeDate
" */"
EndIf

下面是对代码解除注释的宏代码,同样需要选中希望解除注释的代码块,选中的首尾位置可以在首位行的任意位置。

InsertMode
ColumnModeOff
HexOff
UnixReOn
IfSel
Cut
"~@#"
Paste
DeleteLine
"~@@#"
Top
Find "~@#"
DeleteLine
Find "~@@#"
Delete
EndIf

下面是对单行代码加"//"注释的宏代码,这个就简单多了 :-)

InsertMode
ColumnModeOff
HexOff
UnixReOff
"~@#"
Key HOME
IfColNum 1
Else
Key HOME
EndIf
"//"
Find "~@#"
Delete

最后是解除行注释的宏代码:

InsertMode
ColumnModeOff
HexOff
UnixReOff
"~@#"
Key HOME
IfCharIs "/"
Delete
IfCharIs "/"
Delete
Else
"/"
EndIf
EndIf
Find "~@#"
Delete

对行的注释和解除注释不需要选中行,只需要光标落在此行中即可。这里要提一下的是,本来对于行解除注释的宏想写成如下形式的:

InsertMode
ColumnModeOff
HexOff
UnixReOff
"~@#"
Key HOME
IfCharIs "/"
Key Right Arrow
IfCharIs "/"
Key Right Arrow
DeleteToStartofLine
EndIf
EndIf
Find "~@#"
Delete

这样可读性好些,实现逻辑也合理,让人Faint的是,我用的是UEV11的中文版,不支持Key Right Arrow,如果使用宏录制功能,得到的是Key  右箭头 →,但如果手动写Key  右箭头 →,系统就报错,说没有这个命令,真让人不得其解~~~这里由于存在一些逻辑,所以不能录制,只能手写。 <script type="text/javascript"> </script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script>

<script type="text/javascript"> </script><script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值