views:

107

answers:

1

Gnu Emacs is insisting on indenting my typedef as follows:

typedef enum {
    horizontal,
    vertical,
}
    shapes;

I want it to indent as follows:

typedef enum {
    horizontal,
    vertical,
}
shapes;

What switch can I use to get that?

+5  A: 

Go to the line that "shapes" is on, and hit C-c C-o. Then press 0 (as that's the offset you want). Then press Enter. Then press tab to indent. Done.

The docs are pretty clear about this process:

http://www.cims.nyu.edu/cgi-comment/info2html?(cc-mode.info)Interactive%2520Customization

jrockway
You meant to type `C-c C-o RET`.
offby1
Also, your advice doesn't "stick"; the next time he visits that file, or any C file, the indentation will revert to the way he doesn't like. Therefore, he should put this in `~/.emacs`: (add-hook 'c-mode-hook (lambda () (setq c-offsets-alist (cons (cons 'topmost-intro-cont 0) (assq-delete-all 'topmost-intro-cont c-offsets-alist)))))
offby1
The idea you are supposed to glean from my commment is "read the manual", not "here's how to solve the one problem you happen to have today".I don't use cc-mode, and yet I figured out how to do what the OP wanted almost immediately. It's because I looked in the manual.
jrockway
Or, because you knew where to look in the manual. Thanks for your answer.
Kinopiko