In Fundamental mode, I type a tab following typing each number, but it seems the separator between the numbers are not the same length. I was wondering why?

1  22   333     444

2 Answers 2


The Emacs manual (online version) answers your question. Look at the chapter "Indentation" and read the section "Tab Stops".

Spacing between tab stops may vary. Even though tab stops are equally spaced, the spacing between elements may be different because their length probably differ.

Manual setting of tab stops

0       1       2       3       4

one two              three
1   2                3

Spacing between elements

0       1       2       3       4       5       6

one     two     very_very_long_element  end 

This answer does not address Lisp-related behavior when a user has called indent-for-tab-command and the like. The alternative answer by @Fólkvangr in this same thread -- https://emacs.stackexchange.com/a/43866/2287 -- deals with potential whitespace being added before/after a tab character as a result of calling certain Lisp functions.

With potential whitespace and Lisp-related behavior out of the equation, the char-width of a tab is controlled by the local-variable tab-width and the buffer-display-table entry (if any) for tab. The display engine (xdisp.c) treats the tab character as a stretch glyph.

To change the behavior, a user may adjust the tab-width. However, several common major-modes adjust this variable. Therefore, a major-mode hook may need to be used to reset the tab-width to whatever the user prefers. Or, some major-modes may have a variable that can be adjusted that will ultimately affect the tab-width setting when the major-mode is enabled.

Another way to change the behavior is to modify the buffer-display-table to substitute the tab glyph with something(s) that is/are not treated as a stretch glyph; e.g., ». I personally like to have a buffer-display-table entry for a tab that has two characters, one of these » (with a preferred foreground color) and a tab [stretchy] that follows (with some color added to the tab [stretchy] rectangle, such as a shade of grey).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.