nerdcommenter icon indicating copy to clipboard operation
nerdcommenter copied to clipboard

Uncomments real comments

Open jalbalah opened this issue 8 years ago • 2 comments

Unfortunately the "toggle comment" shortcut uncomments existing comments.

E.g. toggling

if true:
    //comment
   foo();

-->

//if true:
    comment
    //foo();

This is an issue for any code with comments! An ideal solution is un/commenting the way SlickEdit IDE works... recognizing start-line comments... -->

// if true:
//     //comment
//     foo();

Here the commenter recognizes slash-slash-space at start of line.

Thanks!

jalbalah avatar Mar 15 '17 16:03 jalbalah

Pardon me if I'm being dense, but I honestly don't see how this is unfortunate at all. It's done exactly what you asked it to and toggled the commented or not commented status of each line. This is a feature I use to my advantage, not one I would envision being a problem. If you have a block of mixed-format content and want to do something specific with it, why not use the comment function instead of the toggle function?

alerque avatar Mar 15 '17 18:03 alerque

Personally, I prefer a "real toggle", but your solution of breaking the toggle into two steps (comment and uncomment) is apparently also buggy with the functions I tried. What comment function would work?

Doing \ci then \cu has the same problem... Doing \c<space> then \cu kind of works, unless the first line selected is a comment...

How do you comment using only // per line, then uncomment, without erasing existing comments? Goal:

//comment
foo();

-->

////comment
//foo();

... Note: Of course, \cc and \cu work, but they use block comments, which unfortunately cannot nest. What I mean by nested comments by example:

#include<iostream>
using namespace std;
int main() {
  /*
   /**/
   */
  cout << "Hello World!" << endl;
  return 0;
}

Error: junk.cpp:6: error: expected primary-expression before ‘/’ token

jalbalah avatar Mar 15 '17 19:03 jalbalah