163K网站系统官方论坛's Archiver

zzsh 发表于 2007-2-16 18:21

.net教程:在ultraedit中用宏实现将选中的代码设置为注释

[size=3]面是对代码块设成注释的宏语句,使用前需要先选中希望注释的代码块,选中的首尾位置可以在首位行的任意位置,这里用的是"/*"和"*/",本来希望做成对每一行加"//",这样就像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  右箭头 →,系统就报错,说没有这个命令,真让人不得其解~~~这里由于存在一些逻辑,所以不能录制,只能手写。



[/size]

页: [1]

Powered by Discuz! Archiver 6.1.0  © 2001-2007 Comsenz Inc.