30

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
sjngm
  • 497
  • 1
  • 5
  • 15

2 Answers2

41

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

unlet! skip_defaults_vim
source $VIMRUNTIME/defaults.vim

set mouse-=a

See :help defaults.vim and :help defaults.vim-explained for details.

jethro
  • 7
  • 3
emyller
  • 526
  • 5
  • 4
3

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.

Rui F Ribeiro
  • 55,929
  • 26
  • 146
  • 227
klaus
  • 171
  • 5