Tuesday, July 29, 2008

Tweaking Vim For Fun and Profit

Vim, to certain extent, amazes me. It can be tweaked in any number of ways. To start with, set your xterm or whatever terminal you use to 256 color palette, as long as it supports 256 color palette. You can check this in your terminfo installation--never thought of what the h*** terminfo and ncurses are for until this point--which for xterm, placed in /usr/share/terminfo/x/*. The file named xterm-256color in that path represents 256-color-xterm. Use the tput command to check if your terminal in X supports 256 color palette, as follows:

tput colors

The output will be similar to:

darmawan@opunaga:~/_Projects/******/svn_checkout/trunk$ tput colors
256

notice the 256 which means it supports 256 colors. If you're using Xfterm4 in XFCE you can easily convert its setting to 256 colors by entering "xterm-256color" to the "$TERM setting" in its Edit|Preferences, akin to this:


Once you get the 256-color terminal, it's the time to tinker with Vim. First, download a good colorscheme for Vim. I recommend zenburn. Then place it in the system-wide vim color setting, which in my case placed in /usr/share/vim/vim71/colors directory. Then do some editing to your ~/.vimrc. Add the following lines:

set nobackup " This line is not related to vim visual tuning, it can be omitted
set writebackup " This line is not related to vim visual tuning, it can be omitted
set number " Show numbers on the left of each line
:colorscheme zenburn " Set the colorscheme to zenburn

Now, with some vim command combination, e.g. '0 (recall last buffer), '1 (recall next to last buffer), split (^Ws), vsplit (^Wv), exchange window (^Wx). You will get something like this:




And by using DejaVu Sans Mono (7 pitch) in Gvim, this is what you'll get:



All in all, Read The Friendly Manual with ":help history" or other topics. It helps a lot to get you up to speed.
Post a Comment

2 comments:

Slinky said...

You've an excellent taste in color schemes ;)

The screenshots of terminal and GVim Zenburns were cool to see! Thanks to Kurt and other contributors they are very, very similar even with limitations in the 256-color terminal mode...

It's a good tutorial so I've added a link to this page to the Zenburn page.

Darmawan Salihun said...

Well, thanks to you and the contributors who made my search for c00l colorscheme didn't last long yesterday ;-).