Inline Comment / Uncomment Block

Could there be an option to comment / uncomment the selected text inline, rather than all of the lines the selected text covers?

So, if I select a block of text and trigger comment / uncomment block, it would be nice if Toad could add /* .... */ comment around just the selected region (or remove them, if the comment markers start and end the region) rather than "--" comment the lines contained within the region. That way I can comment code inline.

Perhaps this could be triggered with a similar keypress like Ctrl + Alt + B and Ctrl + Shift + Alt + B?

Many modern IDEs have this, and it's something I've wanted for ages, unless it already exists and I'm missing it?


I personally like this idea, and hoping that John and dev team take note of it.
Talking about Inline Comment/Uncommenting at the "Selection" level, in addition to the current capability at the "block" level.

BTW, I can sort of mimic what you need by defining my own Make Code Template (see snap below), where I can highlight any portion of code in my Editor and have it commented
(via Ctl-M shortcut, and then Ctl-V to paste the commented code in place)
and it gets pretty close to your requirement.

Problem is that the corresponding Strip (Ctl-P) doesn't seem to be working. Ah well, maybe for now, it might be a useful work-around.

What would Toad have to do when the selected text contains embedded /* ... */ comments?

@Andre I don't think that will happen often because Oracle treats the firsts comment end marker as the ending for the first comment start marker (not nested) See below.

I meant that instead of
I thought the OP wanted to have
which is problematic.

Oh, I see, yes. I guess it would be up to user to not do that if we implement a true block comment instead of multi-line comments.

If there's any nested /* or */ in the selected block you go to comment (which, let's be honest, shouldn't happen very often), it could fall back to full line comments, rather than inline.

This feature has been logged. I played around with Visual Studio Code and their implementation is straight forward. It works on your selection without overthinking edge cases. I think that's a good solution. If you have a bad selection, Undo and try again.

1 Like