My VIM Page

While I'm working, I use VIM as my text editor. Before you mock me too much, I do use Xemacs for some things, like reading mail (VM) and news (GNUS). When most [x]emacs users think of vi, they think of the /usr/bin/vi that ships with most systems. Jeez, if I were forced to use this version of vi, I'd hate it just as much as they did. Fortunately, VIM has much more to offer. Instead of ranting about why I think VIM is cool, check out this page for a dicussion of that exact thing. Anyway, the whole reason that I bring this up is that, like a zealous missionary, one of my goals in life it to convert regular old vi users to VIM users.

Please note that this page refers to Vim6. Some of the info on this page will work with previous versions, butthe structure of the custom syntax files works only with version 6.

My .vimrc

Here is my .vimrc. I do some stuff that make life easier for me and I'll highlight the coolest things.

My VIM Syntax Highlighting Setup

Ok, I'll just say it. I think the default syntax files and colors that come with the VIM distribution really stink! Presented below are my syntax files and screenshots so you can decide for yourself.

First of all, I don't use the GUI version of VIM. I use the 16-color version of xterm that is noted in the VIM docs: I also compile it as noted in the VIM docs to get 16 colors:

./configure --disable-bold-color

Next, I have configured my standard xterm to look good with the colors I've chosen. That stuff goes in my .Xdefaults:

xterm*background: black
xterm*foreground: gray90
xterm*cursorColor: gray90

xterm*color0:                   black
xterm*color1:                   red
xterm*color2:                   green
xterm*color3:                   yellow
xterm*color4:                   blue
xterm*color5:                   magenta
xterm*color6:                   cyan
xterm*color7:                   white
xterm*color8:                   burlywood1
xterm*color9:                   sienna1
xterm*color10:                  PaleVioletRed1
xterm*color11:                  LightSkyBlue
xterm*color12:                  white
xterm*color13:                  white
xterm*color14:                  white
xterm*color15:                  white

xterm*colorMode:                on
xterm*dynamicColors:            on

A few things to note. My standard background and foreground colors are black and grey90 respectively. I've chosen these because I've found them to be the easiest on my eyes. Having a white foreground seemed too harsh. Besides, it makes an actual white syntax highlight stand out more.

Also note that I've made sure that colors 0 through 7 match the standard ANSI colors for an 8 color terminal. This is so applications that use these color codes will look like they are supposed to. The only four colors I've added are 8 through 11. Since I don't use 12 through 15, I leave them white to minimize the number of colors I allocate in my color map.

Before I get into the actual screenshots, I have to give proper credit to my friend Chris Holt from whom I stole the colors.

The reason that I dislike the ditribution syntax files is not merely the colors. I believe that when it comes to syntax highlighting, a less is more philosophy is desired. I believe that when designing a syntax highlighting scheme, you should strive for two things. The first is that the screen should be pleasing to look at and not glaring and harsh. The second is that the colors you choose should help your eyes decompose the screen into its important parts. This means that files in C, Tcl and Perl should most importantly highlight the function and type names, not the type keywords of the language. For example, in the following C code:

typedef struct MyStruct {
    unsigned int                  foo;
    char                         *bar;
    double                        baz;
} MyStruct;

I think the most important thing is for the name of the structure 'MyStruct' to be highlighted as shown above. The default files (and in fact the default files for [x]emacs) will highlight the 'typedef struct' part of the above code like this:

typedef struct MyStruct {
    unsigned int                  foo;
    char                         *bar;
    double                        baz;
} MyStruct;

Why? Well, my guess is that it was very easy to write a regular expression to match 'typedef' and 'struct' while it was more difficult to write one to match the declared type name.

The same idea goes for function declarations and prototypes. My syntax files will highlight the name of the function while the default VIM syntax file as well as most of the ones I've seen for [x]emacs will highlight the return type and/or the word 'extern'. I have no idea why it's important to highlight the word 'extern'. I guess it's just easy to do.

Ok, enough of my ranting. Here is a zipped archive of my syntax files. Look through the screen shots below to decide if you like them. If you like what I've highlighted, just not the colors, then it would be easy to take what I've done and pick new colors. I've created my own versions of the syntax files for the following languages:

Here is a screenshot of a vim syntax file that you can use to see exactly what the 16 color look like. It is very similar to the colortest.vim that is provided in the distribution, except that I've modified it to use color numbers (0 through 15) as opposed to color names. I included my version of colortest.vim in the tarball above.

Last updated on