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 elude开发者_StackOverflowd me thus far.
Put a colorscheme
directive in your .vimrc
file, for example:
colorscheme morning
See here: http://vim.wikia.com/wiki/Change_the_color_scheme
Your .vimrc
file goes in your $HOME
directory. In *nix, cd ~; vim .vimrc
. The commands in the .vimrc
are the same as you type in ex-mode in vim, only without the leading colon, so colo evening
would suffice. Comments in the .vimrc
are indicated with a leading double-quote.
To see an example vimrc, open $VIMRUNTIME/vimrc_example.vim
from within vim
:e $VIMRUNTIME/vimrc_example.vim
It's as simple as adding a line to your ~/.vimrc
:
colorscheme color_scheme_name
You can try too to put this into your ~/.vimrc
file:
colorscheme Solarized
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
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.
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.
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.
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
OS: Redhat enterprise edition
colo schema_name
works fine if you are facing problems with colorscheme.
精彩评论