12

I've been using the default configuration of vim for a while and want to make a few changes. However, if I edit ~/.vimrc it seems to overwrite all other configuration settings of /etc/vimrc and such, e.g. now there is no syntax highlighting. Here is what vim loads:

:scriptnames
/etc/vimrc
/usr/share/vim/vimfiles/archlinux.vim
~/.vimrc
/usr/share/vim/vim80/plugin/... <there are a few>

In other words I want to keep whatever there is configured in vim, but simply make minor adjustments for my shell user.

What do I need to do to somehow weave ~/.vimrc into the existing configuration or what do I need to put into ~/.vimrc so it loads the default configuration?

EDIT:
My intended content of ~/.vimrc:

set expandtab
set shiftwidth=2
set softtabstop=2
  • In my experience, this is not usually the way it works... – Kusalananda Feb 10 '18 at 23:12
  • @Kusalananda Awesome. So how does it work then? – sjngm Feb 10 '18 at 23:22
  • how did ~/.vimrc get to be in the middle of the pack? – thrig Feb 10 '18 at 23:48
  • @thrig I really don't know. – sjngm Feb 10 '18 at 23:50
  • What exactly did you put in vimrc? @thrig not unusual, if you have filetype on, it will load files from $VIMRUNTIME based on file types, and that will be after vimrc – muru Feb 11 '18 at 0:10
11

You can source the global Vim configuration file into your local ~/.vimrc:

source $VIMRUNTIME/defaults.vim
set mouse-=a
  • Awesome!!! It's a good thing that questions don't die around here... :) – sjngm Jul 12 '18 at 16:28
1

What I found out is that the default config (default.vim) is not loaded if you create a ~/.vimrc file, so what I did was to put the contents of the default config into vimrc and to add the modifications at the end.

I am assuming you have vim8 and are using default configurations (i.e. you don't have a ~/.vimrc file)

Copy default config to your user vimrc file:

cp /usr/share/vim/vim80/defaults.vim ~/.vimrc

Then open your ~/.vimrc file and add your configs at the end of it.

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.