Questions
In the following example:
- Why in the first line, a
\t
is inserted but only 4-col blank is displayed? Shouldn't it be8
according totabstop
? - Why the two
<TAB>
hits in the first line and fifth lines have different results? (one is09
and the other is20202020
)
.vimrc
set noexpandtab
set tabstop=8
set shiftwidth=4
set softtabstop=4
Text
I created the following text by first inserting 8 empty lines and then typing at the beginning of each line, so that there is no shiftwidth
generated. (each 4-col blank below is inserted by hitting <TAB>
):
1tab done
2tabs done
3tabs done
4tabs done
1tab
2tabs
3tabs
4tabs
hex representation
Then I did :%!xxd
, this is what I got (with some trailing newlines):
0000000: 3174 6162 0964 6f6e 650a 3274 6162 7309 1tab.done.2tabs.
0000010: 2020 2020 646f 6e65 0a33 7461 6273 0909 done.3tabs..
0000020: 646f 6e65 0a34 7461 6273 0909 2020 2020 done.4tabs..
0000030: 646f 6e65 0a20 2020 2031 7461 620a 0932 done. 1tab..2
0000040: 7461 6273 0a09 2020 2020 3374 6162 730a tabs.. 3tabs.
0000050: 0909 3474 6162 730a 0a0a 0a0a 0a0a 0a0a ..4tabs.........
Related discussion
There are some pretty good answers here but I still don't understand what is going on in this particular case.