Left-justified comment symbols
Michael Mannion last edited by
Is there a shortcut or setting to comment a block of code, while keeping all of the comment symbols in the left-most column?
The current CTRL+K and CTRL+Q behavior produces output like this:
What I want is this:
(Sorry for the cumbersome links; I can’t figure out how to embed code that preserves indents, nor to make the images show up directly.)
Thank you in advance!
rinku singh last edited by
Alan Kilborn last edited by
Ugh. So is this the text you start with?
SELECT column_1 FROM foo WHERE column2 = 99 ;
BTW, in the post composer window, I make that (black code box) happen with this:
You can make this image of yours:
appear like that if you compose it like this:
Michael Mannion last edited by Michael Mannion
Yes, that’s the text I start with. It’s a contrived example, but it has some indents, which is the salient point.
I figured out that I can use Replace with a regular expression and the start-of-line anchor, like this:
It works, but it’s several clicks. Maybe I need to look into making an npp macro; I have one for vim, but am only slowly transitioning my years of customization in vim over to npp.
Just out of curiosity:
- Why the “Ugh”?
I admit I use newlines and indents way more than most developers. Having each column in a SELECT or parameter in a function on its own line, for example, makes things so much easier for me to read - and easier to edit during refactoring. Maybe I’ve just trained myself to think that way; anyway, it is what it is at this point.
Similarly, I can’t imagine why anyone would want their per-line comments indented all over creation. The CTRL+K/Q results are so distracting to me that I have a hard time imagining that anyone is able to glace at that, grasp it, and move on. Syntax highlighting mitigates the problem to the point that it’s probably a non-issue. And, again, I’m willing to admit that I’m the oddball.
I’m not trying to hijack my own thread, but I’m interested in your thoughts. I’m not a full-time developer, though most of my work (DBA / system architect) still involves writing code. I’m always keen to learn from people who code full time.
Lastly, thanks to Gurikbal & you for helping me with the composer syntax.
- Is there a syntax doc page for this composer?
I looked around when I was writing the OP, but didn’t find a help page. Maybe I just missed it. Anyway, I appreciate you both following up. (BTW, I tried to fix the OP to show the images, but got an error that I can only edit within 180 seconds of posting. Stackexchange this ain’t…)
Alan Kilborn last edited by Alan Kilborn
Why the “Ugh”?
That was because if someone wanted to retry your contrived example as-is, they’d have to retype it instead of just swiping it from your posting. Obviously, I went to the trouble to retype it. Ugh. :)
I’m willing to admit that I’m the oddball.
Maybe I’m odd too because I’ve never really understood how those “comment” commands work…why they do what they do. If I did, I certainly would have commented on that aspect in my first reply.
I do a lot of Python, so it is just too easy for me to take this block of code, for ex.:
FindWindow = ctypes.windll.user32.FindWindowW GetWindowText = ctypes.windll.user32.GetWindowTextW GetWindowTextLength = ctypes.windll.user32.GetWindowTextLengthW SendMessage = ctypes.windll.user32.SendMessageW EnumChildWindows = ctypes.windll.user32.EnumChildWindows GetClassName = ctypes.windll.user32.GetClassNameW curr_class = ctypes.create_unicode_buffer(256)
''' FindWindow = ctypes.windll.user32.FindWindowW GetWindowText = ctypes.windll.user32.GetWindowTextW GetWindowTextLength = ctypes.windll.user32.GetWindowTextLengthW SendMessage = ctypes.windll.user32.SendMessageW EnumChildWindows = ctypes.windll.user32.EnumChildWindows GetClassName = ctypes.windll.user32.GetClassNameW curr_class = ctypes.create_unicode_buffer(256) '''
with just a quick manual adjustment. (Interesting, I never noticed that three
'will be changed to TWO in the Compose window, but will still appear as three in the Preview window).
Is there a syntax doc page for this composer?
Yes, see the little
?by the “COMPOSE” text? Click on it…what you get ain’t great, but…
I can only edit within 180 seconds of posting. Stackexchange this ain’t
It ain’t stackoverflow either. Personally, I don’t like those sites where a lot of editing is allowed after the fact. Things can get out of date and hard to follow fast that way. Here, if you make a mistake, you just have to correct yourself later.
Alan Kilborn last edited by
Maybe I need to look into making an npp macro;
You can certainly macro-ize that replace op easily enough. See the Macro menu. Your macro would consist of one thing: A
Replace Allbutton press.