Debian – Creating vimrc breaks vim

colorsdebiantmuxvim

I'm currently logged into a server via ssh with ssh -Y and running a tmux session.

If I start vim and run :colorscheme elflord the color scheme is changed. (Although the colors are not exactly what I would expect although they are I think 256 color.

If I create a ~/.vimrc file and put a single line

colorscheme elflord

in it then when I run vim it shows no color (just white text) and I cannot change the color with the :colorscheme command.

Best Answer

In recent versions of Vim (starting with Vim 8, I believe), if the user has no personal ~/.vimrc file, then Vim will execute the defaults.vim from its runtime directory instead, to load sane defaults.

The usual recommendation is that when you first create your ~/.vimrc file, you should include a couple of lines at the top sourcing the defaults.vim file, in order to preserve the same settings you were getting from that file (which include enabling filetype detection and syntax highlighting.)

See :help defaults.vim, which will tell you to start a new ~/.vimrc file with the lines:

unlet! skip_defaults_vim
source $VIMRUNTIME/defaults.vim

You can then add your colorscheme elflord configuration below these two lines. That should preserve the settings you get by default, but change the colorscheme you use at startup.

Related Question