[vim] How to set default vim colorscheme

The latest upgrade of Ubuntu made my vim colorscheme unusable. I know how to set it manually (:colo evening, for example), but I want to set the default for all vim sessions. I see reference in other places to .vimrc, but the right location and syntax have eluded me thus far.

This question is related to vim color-scheme

The answer is


You can try too to put this into your ~/.vimrc file:

colorscheme Solarized

You can just use the one-liner

echo colorscheme koehler >> ~/.vimrc

and replace koehler with any other available colorscheme. Imho, all of them are better than default.


Ubuntu 17.10 default doesn't have the ~/.vimrc file, we need create it and put the setting colorscheme color_scheme_name in it.

By the way, colorscheme desert is good scheme to choose.


What was asked for was to set:

  • the 'default', not some other color profile, and

  • 'for all vim sessions', not simply for the current user.

The default colorscheme, "for all vim sessions", is not set simply by adding a line to your ~/.vimrc, as all of the other answers here say, nor is the default set without the word 'default' being there.

So all of the other answers here, so far, get both of these wrong. (lol, how did that happen?)


The correct answer is:

Add a line to your system vim setup file in /etc/vim/ that says

colorscheme default

or using the abbreviation

colo default

but not capitalized as

colo Default

(I suggest using the full, un-abbreviated term 'colorscheme', so that when you look at this years later you'll be able to more easily figure out what that darn thing does. I would also put a comment above it like "Use default colors for vim".)


To append that correctly, first look at your /etc/vim/vimrc file.

At the bottom of mine, I see these lines which include /etc/vim/vimrc.local:

" Source a global configuration file if available
if filereadable("/etc/vim/vimrc.local")
  source /etc/vim/vimrc.local
endif

So you can append this line to either of these two files.

I think the best solution is to append your line to /etc/vim/vimrc.local like this:

colorscheme default


You can easily do that in bash with this line:

$ echo -e "\"Use default colors for vim:\ncolorscheme default"  \
   |  sudo tee -a /etc/vim/vimrc.local

# 
#     NOTE:  This doesn't work:
#
#       $ sudo echo 'colorscheme default'  >> /etc/vim/vimrc.local
#
#     It's the same general idea, and simpler, but because sudo doesn't
#     know how to handle pipes, it fails with a `Permission denied` error.

Also check that you have permission to globally read this file:

sudo chmod 644 /etc/vim/vimrc.local

With $ tail /etc/vim/vimrc.local you should now see these lines:

"Use default colors for vim:
colorscheme default

It's as simple as adding a line to your ~/.vimrc:

colorscheme color_scheme_name


Once you’ve decided to change vim color scheme that you like, you’ll need to configure vim configuration file ~/.vimrc.

For e.g. to use the elflord color scheme just add these lines to your ~/.vimrc file:

colo elflord

For other names of color schemes you can look in /usr/share/vim/vimNN/colors where NN - version of VIM.


OS: Redhat enterprise edition

colo schema_name works fine if you are facing problems with colorscheme.


Put a colorscheme directive in your .vimrc file, for example:

colorscheme morning

See here: http://vim.wikia.com/wiki/Change_the_color_scheme


Copy downloaded color schemes to ~/.vim/colors/Your_Color_Scheme.

Then write

colo Your_Color_Scheme

or

colorscheme Your_Color_Scheme

into your ~/.vimrc.

See this link for holokai