Sunday, December 1, 2024

Why change the defaults ?

I see several threads aguing in favour of a change of Vim's defaults.
I believe that such changes are unwise, and here is why :

At the moment, there are several sets of "default" option settings in Vim :
- "compatible" defaults (or "vi defaults") used when the -C switch
is used on the command-line or when you have no vimrc but an exrc
- - These are there to mimic the behaviour of legacy Vi (with the
exception of what Bram regarded as "bugs" in the POSIX description of
Vim). Therefore IMHO they MUST NOT be changed ;
- "POSIX" defaults, used in addition to the "vi defaults" when
$VIM_POSIX is set. These try to make Vim even more like legacy Vi than
just setting 'compatible', even to the point of imitating its
POSIX-entrenched "bugs". For the same reason as above, IMHO they MUST
NOT be changed ;
- "nocompatible" defaults. They are used, for example, if you have
an empty vimrc, or if you put -N -u NONE on the command-line ;
- "defaults.vim" settings. These are set by $VIMRUNTIME/defaults.vim
when no vimrc is found.
- - They are also set if you source either defaults.vim or
vimrc_example.vim somewhere near the beginning of your vimrc, or if
you have -u DEFAULTS on the command-line even if you have a vimrc
(which in that case won't be sourced).

I see several threads proposing to make this or that "defaults.vim"
setting the Vim default for everybody. IMHO this is unwise, because it
is not backward-compatible. If you want those settings even though you
have a vimrc, source the defaults.vim or the vimrc_example.vim from
it. If there are _other_ settings set by the defaults.vim which you
_don't_ want, well, reverse them when Vim comes back to your vimrc
after sourcing them. This is the time-honored backward-compatible way
to do it and if you do it this way instead of changing everyone's
defaults, no one will be surprised.

For instance the defaults.vim contains a line which says
filetype plugin indent on
My preferences go to filetype detection on, filetype plugins on,
filetype indent off. No problem : after sourcing
$VIMRUNTIME/vimrc_example.vim (which calls the defaults.vim nowadays)
my vimrc has a line
filetype indent off
and voilà.

Best regards,
Tony.

--
--
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 visit https://groups.google.com/d/msgid/vim_use/CAJkCKXuTaXJT4_QNGseAPwPQZAZBbc%3D_%3DNkRjGJxp446RCXbXg%40mail.gmail.com.

No comments: