On 14/09/2020 19.08, Anton Shepelev wrote:
> Hello, all
>
> In autoindent and noexpandtab mode, Vim will sometimes
> repace a carefully chosen combination of tabs and spaces
> with another <snip>
This is solved (hopefully) by enabling the 'copyindent' and 
'preserveindent' options.
The problem resurfaces periodically in the mailing lists.
I have run into it recently and have been meaning to say something about it.
There is terrible documentation (in :h 'autoindent' and :h 'smartindent' 
'copyindent' and 'preserveindent' are not mentioned and there are lies 
about what they do by default - "Copy indent from current line"? Not 
really! -), a puzzling arrangement of options (but that's for historical 
reasons) and arguably senseless defaults.
The real behaviour of 'autoindent' and 'smartindent' is better described 
(only) in the documentation of 'copyindent' and 'preserveindent' (but 
even there it's not complete, there should probably also be a mention of 
how Vim converts spaces to tabs - namely looking at the 'shiftwidth' 
option, if I'm not mistaken).
Looking in the repository it seems that the missing correction of the 
'autoindent' and 'smartindent' documentation was an oversight of the 
original patch that introduced copyindent and preserveindent (vim-6-2d), 
and was never corrected.
Does really anyone today require 'auto/smartindent' without 'copyindent' 
and 'preserveindent'??? And for that to be the default??
I read somewhere in vim-dev that some tools did seem to rely on the 
default autoindent behaviour, but even if it were still so breaking 
changes are not unheard of in Vim.
In any case, I think that there should at the minimum be very prominent 
notices that unless you have very peculiar needs you should enable 
copyindent and preserveindent before enabling auto or smartindent.