Better colors so comments aren't dark blue in Vim?
Mostly I edit Ruby files, although shell script file comments are also #
Currently my comments show as dark blue on black which is really hard to read.
See screenshot.
How can I change their color?
I’m willing to consider different schemas for all colors though I do like the black background as a base.
There are many color schemes which are usually distributed together with vim. You can select them with the :color
command.
You can see the available color schemes in vim’s colors
folder, for example in my case:
$ ls /usr/share/vim/vimNN/colors/ # where vimNN is vim version, e.g. vim74
blue.vim darkblue.vim default.vim delek.vim desert.vim elflord.vim
evening.vim koehler.vim morning.vim murphy.vim pablo.vim peachpuff.vim
README.txt ron.vim shine.vim slate.vim torte.vim zellner.vim
I usually use desert
. So I open vim
, then enter :color desert
and enter. To have the color scheme by default every time you open vim
, add :color desert
into your ~/.vimrc
.
(Michael, OP) This was good. The terminal looks like:
One option I found was in terminal preferences (top menu, not the window).
This has profile preferences and then a color tab, e.g.
Changing the Palette entry 5 from Dark blue to Light Lilac helped. I finally chose xterm as the color scheme and lightened up the comment color e.g.
You can do it manually with this command:
:hi Comment guifg=#ABCDEF
Where ABCDEF
is an appropriate color hex code.
To make it permanent, you will need to add these lines to your ~/.vimrc
file (using green as an example):
syntax on
:highlight Comment ctermfg=green
As you are using a dark background in your terminal, you simply need to set
:set background=dark
instead of the default
:set background=light
The colors are then automatically correctly set.
If you want to have this permanently, add the line
set background=dark
to your $HOME/.vimrc
file.
I had precisely this problem a little while ago, the solution is to place the following line in your vimrc file:
set t_Co=256
And then you might have to put the following at the end of your your ~/.profile:
#set vim terminal to 256 colors.
if [ -e /usr/share/terminfo/x/xterm-256color ]; then
export TERM='xterm-256color'
else
export TERM='xterm-color'
fi
and then you can set:
hi Comment ctermfg=lightblue
in your vimrc file and then you will have light blue comments.
vimrc 256: http://vim.wikia.com/wiki/256_colors_in_vim
I also noticed the screen became somewhat prettier by setting it to 256.
If on a dark background in Debian, then uncommenting set background=dark
in /etc/vim/vimrc
helps, too.
Or, if you don’t want to interfere with the package’s config file, rather in (a new)
/etc/vim/vimrc.local
You can generate your own gvim colors and paste them into your vimrc.
Using chrome http://www.hmi-tech.in/activities/gvim-color-scheme-interactive-generator.html
Here is nice git repo with 700+ colorschemes for vim
https://github.com/flazz/vim-colorschemes
clone it to ~/.vim/
git clone https://github.com/flazz/vim-colorschemes ~/.vim/
Preview schemes in vim with
:colorscheme mrkn256
(replace mrkn256
with one of these names ls ~/.vim/colors
(without the .vim
extension ))
To set it permanently edit ~/.vimrc
add/change
colorscheme mrkn256
Maybe too far off topic but here goes
For Windows 10 WSL (Windows Subsystem for Linux)
this worked for me (in .vimrc
)
syntax on
colorscheme desert "(or whatever color scheme)
:colo desert
I use this command to highlight the comments for example 😉
echo "colorscheme elflord" >> ~/.vimrc
Then re-run.
I like it, light comments.
Create a file on user’s home
root@ip-10-100-4-227:~# vi .vimrc
Enter below syntax in file
syntax on
colorscheme desert
Source File
root@ip-10-100-4-227:~# source .vimrc