0

Is it possible to configure C/C++ multi-line comments to comment/uncomment selected text using the preprocessor?

eg:

Before:

    // a comment
    Some(code); /* some comment */

After:

#if 0
    // a comment
    Some(code); /* some comment */
#endif

Since C/C++ don't support nested comments, I find this preferable behavior to quickly disable chunks of code.

  • What do you mean "c/c++ don't support nested comments"? What would this buy you over Emacs's standard commenting logic, which is fairly intelligent? The example you give is possible out of the box. – InHarmsWay Aug 19 '17 at 8:12
  • No, I meant using 'comment-line, you can disable a chunk of code even if those lines themselves contain a comment. Emacs will escape the embedded comment characters. – InHarmsWay Aug 19 '17 at 8:19
  • Nice, I wasn't aware it would escape nested comments, thats handy. Even so, I find it makes for noisy diffs, so would prefer to use the preprocessor. – ideasman42 Aug 19 '17 at 8:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.