DrChip's Vim Colorscheme

I used to primarily use the console version of vim, mostly because the vim session opens to cover the window I'm currently typing in. Here's an example of yacc highlighting using my colorscheme:

You'll note that the background is in "navyblue", which is a dark blue background. You may get a copy of my colorscheme by clicking on astronaut.vba.gz. Insert a copy into your .vim/colors directory (Windows: vimfiles\colors), and use

:color astronaut

in your <.vimrc> or do so by hand. The <astronaut.vim> colorscheme is intended for dark backgrounds!

Nowadays I've switched to using gvim. However, I still prefer that the editing window open atop my terminal window. In order to do that, I use gv.gz, which is a Korn shell script. When run, it sets up a Korn shell function (gv) that opens the editing window as I wish. Note that it sets up a function to do the job; running it doesn't directly open gvim windows, just sets up that Korn shell function.

How does Vim pick colors, anyway?

The <synload.vim> file that Bram wrote defines color data for basic groups: Comment, Constant, Special, Identifier, Statement, PreProc, Type, and Ignore. There are also a number of other highlighting groups that are defined to be links (if you will, aliases) for the basic eight. Check out :he syntax-loading for more about how the syntax files get loaded and how you may define your own.

The syntax loading instructions all get initialized when vim encounters the "syntax on" command in your <.vimrc>. Including colorization commands such as my colorscheme after that event overrides Bram Moolenaar's default settings (in case you somehow don't know, Bram Moolenaar is the author of Vim).

The following example illustrates what happens to the "map" command when it is in a *.vim file. Presumably "syntax on" has already been done. That command caused vim to load <synload.vim> which set ups up an autocmd based on the suffix <.vim>. When a <.vim> file is encoutered, that autocmd fires, and informs vim that the file has filetype "vim". In turn, this causes the <vim.vim> syntax file to be loaded which defines such highlighting groups as "vimIsCommand", "vimCommand", etc., by the use of keywords and regular expressions.

See the example below. The "map" word satisfies the criteria for being a vimIsCommand. The vimIsCommand contains vimCommand(s), which basically is a list of all vim's command keywords. Since "map" is one of them, it is then further recognized as a vimCommand.

vimCommands are linked to the Statement highlighting group. This group is one of the basic eight highlighting groups defined in <synload.vim>. This highlighting group has the actual color specifications which are then used to highlight the word "map".

Note that vimCommand could have been linked to something else which was later linked to one of the basic eight (as are many items in the <vim.vim> syntax file), or a color could have been specified for just vimCommand itself. In my colorscheme file, I do both of these things for mailQuoted2 and mailQuoted3 (which are linked to Cyan and Yellow, respectively, and for which I have set up obvious colors).

ex. based on "map" and <vim.vim>

 +========= 1 ================== 2 =================== 3 =========+
||                     |                    |                     ||
|| Regular Expressions |  Tagged as Various |     Linked to       ||
||    and Keywords     |    Syntax Groups   | Highlighting Groups ||
|| ------------------- |  ----------------- | ------------------- ||
||         map        -->   vimCommand     -->    Statement       ||
||                     |                    |         |           ||
||============================ 4 =====================|===========||
||                                                    v           ||
|| Highlighting Group  (using term, cterm, gui,                 ) ||
||  Specifies Colors   (foreground/background, bold, italic, etc) ||
|| -------------------------------------------------------------- ||
||                                                                ||
|| hi Statement  term=bold ctermfg=Yellow guifg=#ffff60 gui=bold  ||
||                                                                ||

This scheme may seem involved, but it provides the syntax writers and users with considerable flexibility: the user may insert at several points in the process customization files to define his/her own highlighting groups, syntax files, whether to generally have a dark or bright terminal, etc.

The colors themselves (for ctermfg, ctermbg) are often specified via escape sequences in <termcap> or via a terminfo system. In such cases receipt of the escape sequence by the terminal application (xterm, dos window, whatever) causes various colors to appear. The gui often uses colornames typically specified in (for Unix systems) </usr/lib/X11/rgb.txt>. Other o/s's (e.g. Windows) vim drivers specify colors using o/s APIs (ie. functions that the o/s vendor provides for that purpose).

Last Modified Aug 08, 2011 05:16:34 PM © 2011, Charles E Campbell, Jr.