Use Macros in Ultraedit to set the selected code as a comment

Source: Internet
Author: User
Tags ultraedit

This is a macro statement that sets a comment on a code block. You must first select the code block you want to comment on before using it. The selected position at the beginning and end can be any position in the first line, here we use "/*" and "*/". We wanted to add "//" to each row, just like.. NET. Unfortunately, UE macro does not support variables, so I did not expect a good implementation method.

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

The following is the macro code for uncommenting the code. You also need to select the code block that you want to uncomment. The selected Start position and end position can be any position in the first line.

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

The following is a macro code that adds "//" comments to a single line of code. This is much simpler :-)

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

The macro code for removing line comments is as follows:

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

You do not need to select a row to comment or uncomment a row. You only need to place the cursor in this row. Here we will mention that the macro for uncommenting rows should be written in the following form:

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

In this way, the readability is better and the implementation logic is reasonable. What makes people Faint is that I use the Chinese version of UEV11 and do not support Key Right Arrow. If the macro recording function is used, the right arrow of the Key is obtained. However, if you manually write the right arrow of the Key, the system will report an error, saying that this command is not available, which cannot be solved ~~~ Because of the logic, recording is not supported and only handwritten.


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.