macro for commenting/uncommenting multiple lines

Usage tips, posted by users. No questions here please.

Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard

Post Reply
troels_kn
Posts: 32
Joined: Fri Oct 28, 2005 12:51 pm

macro for commenting/uncommenting multiple lines

Post 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).
Post Reply