troubleshooting Question

Emacs C Indentation Customization

Avatar of Primitive
Primitive asked on
Linux OS Dev
3 Comments1 Solution1717 ViewsLast Modified:
I'm trying to customize my C/C++ indentation style.  I'm trying to set this for both C and C++ modes.  The style I'm looking for is this:




Here's the .emacs file I created in my ~/ directory:

(setq c-basic-offset 4)
(setq c-tab-width 4)
(setq c-indent-level 4)
(setq c-brace-offset -4)
(setq c-brace-imaginary-offset 0)
(setq c-argdecl-indent 4)
(setq c-label-offset -4)
(setq c-continued-statement-offset 4)
(setq c-auto-newline t)
(setq c-tab-always-indent nil)

The problem is, changing c-brace-offset appears to have no affect on my indentation in C++ mode.  My theory is that customization is overwriting the stuff I put in this block.  What's the problem, and where do I need to put this code to get it to affect C++ mode?  If I need to create a new mode, how do I do that, and how do I make .c/.cpp/.h files default to that style?

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 3 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 3 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros