Is "vim -C" supposed to override .vimrc?

58 views
Skip to first unread message

Ottavio Caruso

unread,
Feb 13, 2020, 7:03:20 AM2/13/20
to vim...@googlegroups.com
Hi,

this is a snippet or my vimrc:

$ cat .vim/vimrc
source $VIMRUNTIME/defaults.vim
set dir=~/.vim/tmp
set expandtab
set autoindent
iabbrev mydate <C-R>=strftime("%a %d/%m/%Y")
digraph bl 8226 " Insert Bullet with <CTRL>+k bl
map <f5> :1m$<cr>

which sources the default vim system file, which in turn sets
"nocompatible", as expected. So far. so good.

If I start vim with:
$ vim -C somefile

I expect this to turn some features off, for example visual mode with
mouse clicks, but it doesn't. If I manually set "compatible" from the
ex command line, it does turn visual mode off. I assume I could put
this is my vimrc, but I don't want to do this all the time. I could
probably make an alias to:

vim -c "set compatible" somefile

However I wonder if this is intended behaviour or not, that is, I
expected "vim -C" to override vimrc.

My settings:
$ vim --version
VIM - Vi IMproved 8.1 (2018 May 18, compiled Dec 13 2019 20:46:00)
Included patches: 1-2200
Modified by mo...@NetBSD.org
Compiled by oc@e130
Huge version without GUI. Features included (+) or not (-):
+acl -farsi -mouse_sysmouse -tag_any_white
+arabic +file_in_path +mouse_urxvt -tcl
+autocmd +find_in_path +mouse_xterm +termguicolors
+autochdir +float +multi_byte +terminal
-autoservername +folding +multi_lang +terminfo
-balloon_eval -footer -mzscheme +termresponse
+balloon_eval_term +fork() +netbeans_intg +textobjects
-browse +gettext +num64 +textprop
-builtin_terms -hangul_input +packages +timers
+byte_offset +iconv +path_extra +title
+channel +insert_expand -perl -toolbar
+cindent +job +persistent_undo +user_commands
-clientserver +jumplist +postscript +vartabs
-clipboard +keymap +printer +vertsplit
+cmdline_compl +lambda +profile +virtualedit
+cmdline_hist +langmap -python +visual
+cmdline_info +libcall -python3 +visualextra
+comments +linebreak +quickfix +viminfo
+conceal +lispindent +reltime +vreplace
+cryptv +listcmds +rightleft +wildignore
+cscope +localmap -ruby +wildmenu
+cursorbind -lua +scrollbind +windows
+cursorshape +menu +signs +writebackup
+dialog_con +mksession +smartindent -X11
+diff +modify_fname -sound -xfontset
+digraphs +mouse +spell -xim
-dnd -mouseshape +startuptime -xpm
-ebcdic +mouse_dec +statusline -xsmp
+emacs_tags -mouse_gpm -sun_workshop -xterm_clipboard
+eval -mouse_jsbterm +syntax -xterm_save
+ex_extra +mouse_netterm +tag_binary
+extra_search +mouse_sgr -tag_old_static
system vimrc file: "/usr/pkg/etc/vimrc"
user vimrc file: "$HOME/.vimrc"
2nd user vimrc file: "~/.vim/vimrc"
user exrc file: "$HOME/.exrc"
defaults file: "$VIMRUNTIME/defaults.vim"
fall-back for $VIM: "/usr/pkg/share/vim"
Compilation: cc -c -I. -Iproto -DHAVE_CONFIG_H -I/usr/include
-I/usr/pkg/include/ncurses -O2 -I/usr/include
-I/usr/pkg/include/ncurses -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1
Linking: cc -L/usr/pkg/lib -Wl,-R/usr/pkg/lib -L/usr/local/lib
-Wl,--as-needed -o vim -lm -lnsl -lncurses -liconv -ldl



--
Ottavio Caruso

Gary Johnson

unread,
Feb 13, 2020, 12:01:34 PM2/13/20
to vim...@googlegroups.com
On 2020-02-13, 'Ottavio Caruso' via vim_use wrote:
> Hi,
>
> this is a snippet or my vimrc:
>
> $ cat .vim/vimrc
> source $VIMRUNTIME/defaults.vim
> set dir=~/.vim/tmp
> set expandtab
> set autoindent
> iabbrev mydate <C-R>=strftime("%a %d/%m/%Y")
> digraph bl 8226 " Insert Bullet with <CTRL>+k bl
> map <f5> :1m$<cr>
>
> which sources the default vim system file, which in turn sets
> "nocompatible", as expected. So far. so good.
>
> If I start vim with:
> $ vim -C somefile
>
> I expect this to turn some features off, for example visual mode with
> mouse clicks, but it doesn't. If I manually set "compatible" from the
> ex command line, it does turn visual mode off. I assume I could put
> this is my vimrc, but I don't want to do this all the time. I could
> probably make an alias to:
>
> vim -c "set compatible" somefile
>
> However I wonder if this is intended behaviour or not, that is, I
> expected "vim -C" to override vimrc.

From ":help -C":

-C Compatible mode. Sets the 'compatible' option. You can use
this to get 'compatible', even though a .vimrc file exists.
Keep in mind that the command ":set nocompatible" in some
plugin or startup script overrules this, so you may end up
with 'nocompatible' anyway.

Regards,
Gary

Ottavio Caruso

unread,
Feb 13, 2020, 12:52:19 PM2/13/20
to vim...@googlegroups.com
Thanks. I was looking at the wrong section of the help file.

(For posterity, setting "mouse=r" did what I meant to do).


--
Ottavio Caruso
Reply all
Reply to author
Forward
0 new messages