Page 1 of 1

macro for commenting/uncommenting multiple lines

Posted: Sun May 20, 2007 6:58 pm
by troels_kn
In C-like languages (Including PHP and Java), you often have to comment out a block of text, and you can't always use the block-type comments /* */ because they don't nest. For this purpose, I have a macro, which comments out the selection, and a counterpart, which does the opposite.

To implement:

Select some lines of text.
(begin macro)
From the menu select: Search > Replace
[X] Regular expressions
Scope: Selected text
Find what: ^
Replace with: //
Press 'Replace All'
Press 'Close'
(end macro)

For the opposite:
Select some lines of text (presumably the same as above).
(begin macro)
From the menu select: Search > Replace
[X] Regular expressions
Scope: Selected text
Find what: ^//
Replace with:
Press 'Replace All'
Press 'Close'
(end macro)

I have these macros mapped to Ctrl+(The key above Tab) and Ctrl+Shift+(The key above Tab).