Geyslan Gregório
Geyslan Gregório

Reputation: 1122

C Comment in Emacs - Linux Kernel Style

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?

Upvotes: 5

Views: 1015

Answers (2)

Geyslan Gregório
Geyslan Gregório

Reputation: 1122

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

Upvotes: 0

Anler
Anler

Reputation: 1993

Try with:

(setq comment-style 'extra-line)

Upvotes: 6

Related Questions