Emacs C++-mode incorrect indentation?

前端 未结 5 1747
我在风中等你
我在风中等你 2020-12-07 12:54

I\'m running emacs 23 with c++-mode and having some indentation problems. Suppose I have this code:

void foo()
{
   if (cond)
     { <---
        int i;
          


        
5条回答
  •  [愿得一人]
    2020-12-07 13:22

    This is mine... this matches the default setup for visual studio.

    (defun my-c-mode-common-hook ()
     ;; my customizations for all of c-mode, c++-mode, objc-mode, java-mode
     (c-set-offset 'substatement-open 0)
     ;; other customizations can go here
    
     (setq c++-tab-always-indent t)
     (setq c-basic-offset 4)                  ;; Default is 2
     (setq c-indent-level 4)                  ;; Default is 2
    
     (setq tab-stop-list '(4 8 12 16 20 24 28 32 36 40 44 48 52 56 60))
     (setq tab-width 4)
     (setq indent-tabs-mode t)  ; use spaces only if nil
     )
    
    (add-hook 'c-mode-common-hook 'my-c-mode-common-hook)
    

提交回复
热议问题