Monday, September 14, 2020

Re: Tabs and spaces in autoindent mode (and Does anyone today need auto/smartindent without copy and preserveindent?)

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.

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/f3e3daf2-e4b8-4a0a-4db1-d9d1b2b71151%40tiscali.it.

No comments: