Bug#438560: Should -N/-C override 'compatible' settings in vimrc files?

Bram Moolenaar Bram at moolenaar.net
Wed Feb 6 20:43:33 UTC 2008


James -

> It's a common paradigm for option priority to be "system-wide config is
> overridden by the user's config which is overridden by command-line
> options".  This is mostly followed by Vim except that -N/-C command-line
> optons only "stick" if $VIM/vimrc or $HOME/.vimrc don't also affect the
> 'compatible' option.
> 
> This can lead to a counter-intuitive behavior of, for example, Vim
> starting in 'nocompatible' mode when the user specified -C because of a
> 'set nocompatible' in one of the startup scripts.  While the user could
> explicitly elide the startup scripts with -u/-U, doing so would also
> require that they perform any other configuration that is in the startup
> scripts manually.  It seems that honoring the request to at least start
> in the mode specified by the user on the command-line is the right thing
> to do.
> 
> I've attached a patch which implements this behavior to ignore changes
> to the 'compatible' option during startup if -N/-C have been used but
> I'd like to get your input before considering applying it to the Debian
> package.

The main reason to do it this way is that when a startup script contains
"set nocp" the following lines often depend on this.  If one would start
"vim -C" and the -C would cause the "set nocp" line to be ignored, the
rest of the script would be misinterpreted.  Especially for ":map"
commands with things like "<C-A>".  With 'nocompatible' this means
CTRL-A, with 'compatible' this is 5 separate characters.

One could think of having the "set nocp" only apply to that script and
restore the 'compatible' option value after it has been sourced, but
that is a bit complicated.

- Bram

-- 
A)bort, R)etry, B)ang it with a large hammer

 /// Bram Moolenaar -- Bram at Moolenaar.net -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\        download, build and distribute -- http://www.A-A-P.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///





More information about the pkg-vim-maintainers mailing list