What’s Your Favorite Color (Scheme)?
Let’s begin with the simplest of configurations. We’ll customize our environment to a color scheme we prefer. This is simple, and uses one of the basics of Vim scripts, the simple Vim command.
Vim ships with 17 customized color schemes. You can choose and activate a color scheme by putting the colorscheme command in your .vimrc or .gvimrc file. A favorite “understated” color scheme of one author is the desert scheme:
Put a colorscheme like that in your configuration file, and now every time you edit with Vim you will see your favorite colors.
So our first script is trivial. What if your tastes for your color scheme are more complex? What if you like more than one color scheme? What if the time of day correlates to your preferences? Vim scripts easily let you do this.
Choosing an alternate color scheme depending on the time of day may seem trite, but maybe not as much as you may think. Even Google changes the colors and tone of your iGoogle home page throughout the day.
One of the authors likes to divide the day into four partitions, each with its own dedicated color scheme:
Midnight to 6 a.m.
6 a.m. to noon
Noon to 6 p.m.
6 p.m. to midnight
We’ll build a nested
of code for this purpose. There are a couple of
different syntaxes you can use for this block. One is more
traditional, with an explicitly laid out syntax:
line of vim code
another line of ...