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.