commenting out blocks of code
Duncan Booth
duncan.booth at invalid.invalid
Sat Feb 18 06:05:47 EST 2006
Steven D'Aprano wrote:
>> Scite, for example, lets me selected a block and hit Ctrl-Q to either
>> comment or uncomment the block.
>
> I see the developers of Scite are either newbies to GUI programming, or
> they operate in a world of their own. Ctrl-Q is reserved for Quit (or
> Exit) in every GUI API I know of.
Your experience obviously differs from mine. I just tried Ctrl-Q on both
windows and ubuntu and in neither case did it exit applications
consistently: For example Firefox uses Alt-F4 in both cases.
My own favourite editor (Epsilon) uses Ctrl-Q for the 'quoted-insert'
command (hardly suprising given its similarity to emacs).
>> (It does this by prefixing each line
>> with #~ instead of just #, which allows it to detect when a line is
>> already so commented and reverse the operation.)
>
> It is *easy* to detect when a line is already commented. It starts with a
> #. The ~ is superfluous.
>
Not so easy if the lines to be commented already contain some lines
starting with comments. Messing around with the comments themselves sounds
highly unsatisfactory though.
I agree with you that the best solution is to use different commands (or as
Epsilon does a single command which can be modified with a prefix Ctrl-U).
That way I can select a large region and comment it all out, or uncomment
disjoint parts of it as I choose.
More information about the Python-list
mailing list