1

Launch Emacs with emacs -Q, insert a line contains only a \t (| represents the cursor):

\t|

M-x whitespace-mode, it should looks like (_ represents visual space):

»________$

Insert 2 spaces at the beginning of the line, it should now looks like:

··»______$

But what i want is:

··»________$

I'm a little confused why Emacs doesn't display the \t and 2 spaces before separately. Is the before 2 spaces really inserted? Can anyone help me?

Edit:

I encounter this problem when using whitespace-mode to show tab mark. The details can be found here.

littleqz
  • 117
  • 3

1 Answers1

2

Tabs are not displayed as a fixed amount of spaces but as whitespace stretching up to the next tab stop. The elisp manual says:

The tab character (character code 9) displays as whitespace stretching up to the next tab stop column. *Note (emacs)Text Display::. The variable ‘tab-width’ controls the number of spaces per tab stop (see below).

C-h vtab-width says (emphasis mine):

...

Documentation: Distance between tab stops (for display of tab characters), in columns. NOTE: This controls the display width of a TAB character, and not the size of an indentation step. This should be an integer greater than zero.

JeanPierre
  • 7,465
  • 1
  • 20
  • 39