5

I'm using

(setq-default comment-style 'multi-line)

and my region comments, when doing M-;, are:

/* void main()
 * {
 *  int i;
 *  int b;
 *  printf("format string");
 * } */

But I want them to look like this:

/* 
 * void main()
 * {
 *  int i;
 *  int b;
 *  printf("format string");
 * }
 */

What do I have to change?

2 Answers 2

6

Try with:

(setq comment-style 'extra-line)
2
  • 1
    That worked like a charm. Thanks. Emacs really rocks. Apr 19, 2014 at 19:31
  • I noticed that last line of the comment has spaces and not tabs. How could we cincumvent that to use only tabs for comment alignment? Jan 10, 2016 at 17:13
0

Complementing the anler answer and answering my own question.

To use the Linux Kernel commenting Style [1] in emacs, just set this variable in your .emacs/init.el:

(setq comment-style 'extra-line)

To comment/uncomment use M-; after select the region.

To fix needless comment spaces when using tabs see C Comment in Emacs - Linux Kernel Style v2.

[1] https://www.kernel.org/doc/Documentation/CodingStyle

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.