Shivam
Shivam

Reputation: 2132

Custom emacs indenting c mode

The coding format style that is used at my work is as follows:

public:
   TraceIndent(int i = 0) : _i(i)
      {
      if (_i)
         {
         nesting++;
         }
      }

Tabs are three spaces but no indentation after braces. Is it possible to achieve such style of formatting for c-mode in emacs?

Upvotes: 1

Views: 159

Answers (2)

gooddocteur
gooddocteur

Reputation: 109

You could add this to init.el and enjoy manual formatting (add-to-list 'c++-mode-hook (lambda () (setq c-syntactic-indentation nil)))

Upvotes: 0

Shivam
Shivam

Reputation: 2132

Seems like I solved my problem. After researching a bit, I found that this kind of style is know as "whitesmith". I put these lines in my emacs init.el, which solved the issue. Hopefully, it will be helpful to someone.

(setq c-default-style "whitesmith"
      c-basic-offset 3)

Upvotes: 4

Related Questions