Length of tabs after initial char
gvim with the
--clean option, to get a clean slate, and then do:
:set noet ts=5 sts=3 sw=2
Then enter the following
and on the next line, press tab twice. The cursor will end up between the 6 and the seven (I use two bars to make it more obvious):
and if you replace spaces with a dot (to see where they are), doing
:%s/ /./g you will get:
Meaning there will be a tab with the length of five spaces, before that last space, that is now a dot. This is how I expected things to function: you add
sts spaces until there is more than
ts spaces, at which point you replace
ts spaces with an actual tab (and keep any remaining spaces).
But now suppose you add a character before the tab (let us say an
a). Pressing tab twice will still move the cursor in the same way, i.e., first after the 3, then after the 6. But if you now do the same substitution, you will get a tab that has length 4! (from indexes 2 to 5)
123456|7890 a .|
Repeating with the experiment with two starting characters will produce a tab with length 3:
123456|7890 ab .|
But this seems to only happen with the first substitution: for any subsequent ones, the tab will indeed have length 5.
So my question is: why does
vim behave in this manner? In could not find an explanation for this in the docs.
Thank you for your help.