0

My friend and I collaborate on a C++ project and we agree to use 4 whiltespaces for indentation. I am using Emacs and this is my indentation setting

(setq-default c-basic-offset 4) 

By doing this, I believe that I can use tab safely without pressing the space bar for 4 or 8 or 12 times. However, my friends (Eclipse user) and I see awkwardly indented (misaligned) code in our own code editor. Then we accuse each other for using tabs instead of 4 whitespaces.

How can I find the ground truth in our cpp file? We want to know who introduces \t to our code.

We use svn for source control and do not have a nice UI for code review. So I prefer to check this \t character locally.

1

1 Answer 1

2

First of all you should set the default value of indent-tabs-mode to nil. Either toggle it off with customize or put the following lisp code into your init file.

(setq-default indent-tabs-mode nil)

You can check for tabs in a file with M-x white-space-mode in its buffer. Tabs are indicated with » when that mode is active.

If you want to prominently highlight tabs permanently you can use the following code from emacswiki in your init file.

;; Draw tabs with the same color as trailing whitespace  
(add-hook 'font-lock-mode-hook  
      (lambda ()  
        (font-lock-add-keywords  
         nil  
         '(("\t" 0 'trailing-whitespace prepend)))))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.