emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: In go-ts-mode, tab-width 4 inserts two tabs instead of one


From: BTuin
Subject: Re: In go-ts-mode, tab-width 4 inserts two tabs instead of one
Date: Tue, 26 Sep 2023 15:02:29 +0200
User-agent: Mozilla Thunderbird

Le 26/09/2023 à 14:31, Pankaj Jangid a écrit :
"Augustin Chéneau (BTuin)" <btuin@mailo.com> writes:

That's because tab-width only controls the appearance of a
tabulation.

I actually want this only. That is, I want to control the appearance of
tabulation only.

In go-ts-mode, the indentation offset is set by the variable
go-ts-mode-indent-offset.  Since it is 8 by default and that you have
set tab-width to 4, it inserts two tabs to keep the offset of 8.

So you simply need to set go-ts-mode-indent-offset to 4 or directly to
tab-width (with (setq go-ts-mode-indent-offset tab-width)).

Setting both, tab-width and go-ts-mode-indent-offset, to 4 results in
the desired behaviour. But I did not understand this.

The doc string of go-ts-mode-indent-offset says, "Number of spaces for
each indentation step". But when I set both to 4, it uses TAB (which I
want), and not SPACEes.

Is this variable explained in detail elsewhere?


So I don't know this very well, but from my understanding it replaces spaces with the equivalent tabs.

For instance, if you set tab-width to 4 and go-ts-mode-indent-offset to 4, it will insert 4 spaces or equivalent, which are here equivalent to 1 tab, so it will insert one tab instead.

If go-ts-mode-indent-offset is set to 6, it will insert 6 spaces or equivalent, which are here equivalent to one tab plus 2 spaces.

It you want to use spaces only instead, you might want to look at indent-tabs-mode.

There is also more information in the Emacs manual at "Indentation" (<https://www.gnu.org/software/emacs/manual/html_node/emacs/Indentation.html>) and in EmacsWiki (<https://www.emacswiki.org/emacs/IndentationBasics>).






reply via email to

[Prev in Thread] Current Thread [Next in Thread]