Page 1 of 1

Intelligent Line Commenting

Posted: Fri Jan 22, 2010 2:02 pm
by ds0934
I've tried the macros for commenting lines of code, but they seem to work best for only certain languages. I would like to see a menu/keyboard feature to "Comment/Uncomment" selected lines where it uses the comment setting from the syntax file for the detected document class. I should be able to select the lines of code, and either click on a menu item or press something like CTRL+K or whatever, and have it insert or remove (toggle) comment character insertions.

Better than that, would be for languages that support multi-line comments, like PHP, C++, Perl, Java, PowerShell, it would insert only two demarkations in the file (start and end symbols) where languages that do not (ie. VBscript) simply inserts the single-line comment character on each selected line. Even if it could only do the latter for all languages that would be very helpful.

Posted: Thu Jan 28, 2010 4:01 pm
by Drxenos
The advantage of single-line comments is there are no issues with existing comments for languages that don't allow multi-line comments to nest. When I setup commenting macros, I always use single-line comments for this very reason. I can comment-out a block without regard for what the block contains. That is not always possible with multi-line comments, or even the preprocessor (for languages that have one).

I do, however, like your idea about having the same keyboard shortcuts that will comment/uncomment regardless of the language. That would be nice.


DrX

Posted: Tue Nov 16, 2010 8:18 pm
by Faded Giant
I would like to see this feature also!

Not to sound selfish, but I've been using MS Visual Studio and Cypress PSoC Designer for several years, and have become a frequent user of this feature. Both of these environments use Ctrl-K, C (Hold Ctrl, press K, while still holding Ctrl, press C) to comment a selection, and Ctrl-K, U to un-comment a selection.

For single-handed mouse operations, you can select several lines, then click on one of two icons in the toolbar to comment/un-comment.
I would include images of these, but I am new to this forum (or any other forum for that matter) and I don't understand how to use the "Img*" button to attach a picture.

Agree

Posted: Mon Nov 22, 2010 4:23 am
by peterl
I agree too this would be good.
IDEs often use Ctrl-3 or Alt-3 to comment and Ctrl-Shift-3 or Alt-Shift-3 to uncomment. I like this because # is used by lots of scripting languages for commenting, so it's an obvious one to remember.