0

I don't have a personal vimrc. I use /etc/vimrc. The last 2 lines are:

let testvar=999
filetype indent off

I confirmed execution at the vim prompt using :echo testver, which displays 999.

I tried to create a Matlab file using gvim RndSquare.m. My first typed line is:

function m = RndSqure( n )

The following line always start indented, which I don't want.

The only way to prevent it seems to be to create ~/.vim/indent/matlab.vim containing let b:did_indent = 1. I also had to create tex.vim containing the same line, for the same reason.

I don't want to create a gazillion files, one for each file extension, and all containing the same line. Why are the last 2 lines in my vimrc ignored?

Vim version:

VIM - Vi IMproved 8.1 (2018 May 18, compiled Jul 28 2019 14:56:47)
Included patches: 1-1772
Modified by <cygwin@cygwin.com>
Compiled by <cygwin@cygwin.com>
Huge version with GTK3 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/dyn          +toolbar
+cindent           +job               +persistent_undo   +user_commands
+clientserver      +jumplist          +postscript        +vartabs
+clipboard         +keymap            +printer           +vertsplit
+cmdline_compl     +lambda            +profile           +virtualedit
+cmdline_hist      +langmap           +python/dyn        +visual
+cmdline_info      +libcall           +python3/dyn       +visualextra
+comments          +linebreak         +quickfix          +viminfo
+conceal           +lispindent        +reltime           +vreplace
+cryptv            +listcmds          +rightleft         +wildignore
+cscope            +localmap          +ruby/dyn          +wildmenu
+cursorbind        +lua/dyn           +scrollbind        +windows
+cursorshape       +menu              +signs             +writebackup
+dialog_con_gui    +mksession         +smartindent       +X11
+diff              +modify_fname      +sound             -xfontset
+digraphs          +mouse             +spell             +xim
+dnd               +mouseshape        +startuptime       +xpm
-ebcdic            +mouse_dec         +statusline        +xsmp_interact
+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
1

I don't have a personal vimrc.

Then Vim sources $VIMRUNTIME/defaults.vim You can see this by issuing :scriptnames

Why are the last 2 lines in my vimrc ignored?

They are not. The last line gets effectively cancelled by the line filetype plugin indent on from defaults.vim, because it gets sourced after it.

The last 2 lines are:

This is a huge mistake, because you are trying to abandon indenting, while you rely on defaults to switch filetype on. That cannot work. So you must create ~/.vimrc If you need at least filetype stuff without indents you have to add filetype plugin on to it. Otherwise you can keep it empty.

  • I followed this solution to add let skip_defaults_vim=1 at the end of /etc/vimrc. Why is $VIMRUNTIME/defaults.vim needed when we already have a system-wide vimrc? – user2153235 Mar 20 '20 at 20:33
  • @user2153235 You still probably need some stuff from defaults.vim, such as filetype plugin on, autocommand to go to the last known position etc. – Matt Mar 21 '20 at 3:57
  • Sorry, what I meant was why functionality is now split up between two start-up files? Thanks. – user2153235 Mar 22 '20 at 4:48
  • @user2153235 Well, personally I had to split all the stuff into around fifteen files, not counting plugins, of course. And that's not the limit, just see what the monsters like SpaceVim and such look like. But what I don't get is the value of having /etc/vimrc. IMO, vim config must be truly personal. – Matt Mar 22 '20 at 5:27
  • Most laptops these days are used by individuals, with different accounts for different purposes, e.g., administrator for housekeeping, personal, work, temporary for testing, etc., but one's vim habits don't change. This is one use case for a common vimrc across accounts. You said that you would like to see many vim configurations, but vimrc and defaults.vim are not language specific. why is there a need for those two? – user2153235 Mar 23 '20 at 1:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.