Emacs: How to use white spaces instead of tabs when writing C or Vala code

Many projects have their own policy regarding the code style, so it can happen to you that while working on one of them it is required to use white spaces as indentation instead of commonly used tabs. To activate this feature within the emacs editor only when working with C or Vala source code you can place this in your ~/.emacs file:

(add-hook 'c-mode-hook (lambda () (setq indent-tabs-mode nil)))
(add-hook 'vala-mode-hook (lambda () (setq indent-tabs-mode nil)))

A small note: If it should be applicable for a specific project one can combine the above feature with Directory Variables.

Additional references: spaces instead of tabs

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s