April 15, 2017

Fedora and Vim

Today I went out to my computer, stoked to work on some software, fired up Vim and discovered that it was unexpectedly using some hopeless color scheme. This wasn't as bad as the last time this happened. The last time the new scheme came along as part of a new fedora release and of course I was desperate to use vim to straighten out some configuration files.

There is no telling what the Fedora people are thinking with this. Their terminal window must have something other than a plain black background that most of the colors just fade into. Whatever the case I want to have a vim setup that is immune (or as immune as possible) to whatever winds of change blow through the minds of the Fedora crew. But I do have to say that any color scheme that does not also control the background, i.e that does not ensure a useable editor is broken.

Vim is not vi

I may as well warn you about this pitfall. In a default Fedora install /bin/vim and /bin/vi are very different things. I have been typing "vi" since before linux and vim even existed and there is no way in hell I am going to change. My simple fix for this is to place an alias in my .bashrc.
# Fedora vi is some horrible thing.
alias vi='vim'
If you are trying to use a .vimrc and use interesting vim features and nothing is working right, this is why.

Color schemes

I love vim syntax highlighting. It catches all kinds of things that would otherwise pass on to the C compiler and waste my time. But you do need a sane color scheme, and there are myriads of them available. To find out what color schemes are installed on your system, type ":colo ". When I do this, I get:
blue       darkblue   default    delek      desert     elflord    evening    industry   koehler
morning    murphy     pablo      peachpuff  ron        shine      slate      torte      zellner

Incidently the new broken Fedora scheme looks a lot like "peachpuff".

So, I can just add a single line to my .vimrc to pick one of these:

colorscheme blue
Using the locate command and typing "locate zellner" shows me these are installed at:
/usr/share/vim/vim80/colors/zellner.vim

However, haven't we just learned that we cannot (and do not want to) trust the Fedora vim setup files?
Who knows when they will decide to change or get rid of zellner or peachpuff or some other scheme
that we decide that we like and get used to.

Installing a non-fedora provided color scheme

I looked at the above and decided that I liked "basic-dark". There is also a brother scheme called "basic-light". You can get both of them via:
git clone https://github.com/zcodes/vim-colors-basic.git
The fetches both files: basic-dark.vim and basic-light.vim

The big secret

The place to put these color scheme files is in .vimrc/colors !!!

Since I discover I actually like "elflord" pretty well, I make a private copy of it like this:

cd
cd .vimrc
mkdir colors
cd colors
cp /usr/share/vim/vim80/colors/elflord.vim .
Then put "colorscheme elflord" in your .vimrc and you are safe for the time being. Now I just have to let my brain adjust to the new "elflord" colors.


Have any comments? Questions? Drop me a line!

Adventures in Computing / tom@mmto.org