I want all tabs to be 4 spaces. I have the following in .emacs
(setq-default indent-tabs-mode nil)
(setq c-basic-indent 4)
(setq tab-width 4)
But this gets overwritten by some of the major mode themes that I can use. Is there a way to force this issue through my .emacs
file?
Try this to overwrite whatever any major mode overwrites:
(add-hook 'after-change-major-mode-hook
'(lambda ()
(setq-default indent-tabs-mode nil)
(setq c-basic-indent 4)
(setq tab-width 4)))
Note though that major modes that aren't based on c-mode
are not likely to care about c-basic-indent
and may potentially use their own, mode-specific indentation variables. In such cases, there's no way around configuring these variables manually.
Declare a default C indentation style, rather than declaring specific style parameters.
(setq c-default-style "k&r2") ;; or whatever your preference is
(set-default 'indent-tabs-mode nil)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With