How to get Emacs to use tabs instead of spaces?

I attached the command indent-for-tab-commandto one of the keys, and I want him to indent smartly in mode, like him, but with tabs. In all modes. It always inserts spaces instead of tabs. How to reconfigure / reprogram it?

I want to use Emacs as a fully customizable editor, as announced. So that he behaves the way I want. I am not at all interested in the opinions of the developers and I want to customize everything. It is not right?

+4
source share
1 answer

Not all major modes handle the indent the same way, so you may have to make some adjustments to certain modes to get the behavior you need. Often they will have their own indentation settings, for example. cperl-indent-level.

In modes based on cc-modefor 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)

Please note that there are some interesting situations that may arise when using tabs for indentation. EmacsWiki Home

+5
source

Source: https://habr.com/ru/post/1527013/


All Articles