I've binded a indent-for-tab-command
command to one the keys and I want it to make smart mode-specific indentation just like it already does but with tabs. In all the modes. It always inserts spaces instead of tabs. How to reconfigure/reprogram it?
I want to use Emacs as fully customizable editor as it's announced to be. So that it would behave exactly as I want. I do not care about developers' opinions at all and want to customize everything. Is this wrong?
Not all major modes handle indentation the same way, and so you may have to make some adjustments to certain modes to get the behaviour that you want. Often they will have their own indentation settings, e.g. cperl-indent-level
.
In cc-mode
based modes for C-like languages, something like this should do what you want:
(setq-default indent-tabs-mode t)
(setq-default tab-width 4) ; Assuming you want your tabs to be four spaces wide
(defvaralias 'c-basic-offset 'tab-width)
Note that there are some interesting situations that can come up when using tabs for indentation. The EmacsWiki indentation basics page is worth reading, if only to understand how Emacs treats indentation differently from other editors.
Edit:
For ruby-mode
, this should work (assuming you've already set tab-width
as above):
(setq ruby-indent-tabs-mode t)
(defvaralias 'ruby-indent-level 'tab-width)
For sgml-mode
-derived modes, including html-mode
:
(defvaralias 'sgml-basic-offset 'tab-width)
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