Toggle Single Line Comment suggested change

  • I don’t know who if anyone would agree but I believe the Toggle Single Line Comment should work differently. There are issues when using it to comment blocks of code. As it is now:

    // comment

    After Toggle Single Line Comment
    // code
    // code

    Not very useful. You might say use the block comment then. Well if you have any block comments buried in the block you are commenting out now you have a mess.

    I would argue that the Toggle Single Line Comment command should be two commands a Line Comment and Line Uncomment. Line Comment should add a line comment marker at the beginning of every selected line regardless of whether or not it’s already commented. And conversely Line Uncomment should remove only one comment marker per line (if present). The above example becomes:

    // comment

    after Line Comment:
    // code
    // // comment
    // code

    and after Line Uncomment:
    // comment

    I know that for languages without a block comment marker, like VHDL, the Block Comment/Uncomment works by commenting/uncommenting each line which is fine and that allows commenting large mixed block of code/comments. But for those languages with block comment markers like the Verilog, used in the example above, you are left no way to comment large blocks of mixed code/comments without issues.

    Thanks for listening,
    Ray Haynes

  • @Ray-Haynes :

    I feel your pain. I’ve always found the Comment commands in Notepad++ lacking.

    Are you asking for workarounds or just suggesting a change?

    As a workaround, here’s what I do: I go to the first line I want to comment out and start a column-block with Shift+Alt+Down. I proceed down with the column blocking until I get to the last line I want to comment out (I now have a tall skinny caret). Then I press # (Python) or // (C family). Bam, all the lines now have single-line comment characters at their start. Removal involves another column block to highlight the # or // and then a Delete key press. Of course this gets kind of clunky when you have a really large amount of lines to treat. But for the most part that isn’t the case.

    Your best option is to make a feature request or a change-in-functionality request here by opening a “New issue”. However, please spend a little time searching to see if your specific request already exists, in which case you can “up-vote” that Open Issue so that in theory it gets more attention. You may also add to an already open Issue any new information you think relevant. You may search open issues (at the above link) as follows:

    • Make sure the Issues “tab” is active
    • The box to the right of the Filters dropdown (with the magnifying glass in it) should already have is:issue is:open in it
    • Add a space and then your search term to that box and press Enter

    If this (or ANY posting on the Notepad++ Community site) is useful, don’t reply with a “thanks”, simply up-vote ( click the ^ in the ^ 0 v area on the right ).

  • I’m confused. @Ray_Haynes You say Toggle Comment should be two commands, but there are already two other commands. Single Line Comment and Single Line Uncomment and they behave exactly as you suggest. I don’t think I’ve ever used Toggle, I’ve always used Cntrl-K and Cntrl-Shift-K (Edit->Comment/Uncomment) for commenting. I would have to switch editors if this wasn’t available. What am I missing in this conversation?

  • @cipher-1024 - I’m using 7.4.2 and on Win7-64 and I don’t see Single Line Comment and Single Line Uncomment only the Toggle Single Line Comment option. Maybe it’s a context menu thing but tried it on VHDL/Verilog/Bat/Cmd files and Toggle was there. So I don’t know what is going on. But I just tried the Ctrl-K / Ctrl-Shft-K and it does work correctly which is good solution. I’m more of a mouse guy than a total keyboard guy so the right click menu is appealing.

    @Scott Sumner - Thanks for the column comment insert suggestion. I might like that the best since the markers are placed at the start of the line. Also I’ll head over to github and see if I can find any info there.

    Thanks All,

  • Hi Ray,
    You should see all the comment choices if you go up to the window menu->edit->Comment/Uncomment. If you want to add the options to a mouse-centric world, go up to Settings->Edit Popup ContextMenu and add an item like this:
    <Item MenuEntryName=“Edit” MenuItemName=“Single Line Uncomment”/>

    I agree that sometimes it would be nice if the comment marks were all the way to the left, but there are other times where that would interfere with seeing the structure of the code, so for me it’s 50/50.

    Good Luck

Log in to reply