Saturday, February 17, 2007

Indent level highlighting

I have finally begun to delve into the world of VIM syntax highlighting. The syntax used by VIM that give all my different files such pretty colors have always been something of a mystery to me. Recently a problem caused me to make the jump into the :help syntax pages.

There was on my part some assumption that someone had already done what I wanted to do, which is to highlight each successive indent level in a file. This would be particularly helpful for python files, but other programming languages as well. The BlockHL looked like just what I was looking for. Interesting, and helpful, but not quite.

Delving into the documentation I eventually found after much scratching of the head how to do exactly what I wanted to. Piddling around with the highlight colors I came up with three variations. I think I like the right most one best.





















BlockHL syntax pluginProgressively darker indenting, kinda loud.


Alternate coloring. Better.Alternate color, with progressively darker shading. Best.

I've posted the very simple coloring script on vim, as a script plugin. See its page for further details.

*** update ***

Well well well, apparently some poeple actually read my postings sometimes and call me out on my shoddy programming skillz. Yes, its true. This plugin only works with TABs. Maybe if I get less lazy, I'll make it work with the tabstop/shiftwidth settings for you non tab users.

Tuesday, February 06, 2007

switching between bash and batch scripts.

Were it only as easy as s/sh/tch/! Well, it almost is.

For the most part only a few search replaces are required. Most of the tme I need to convert a dos batch to a bash script. The first round of conversion includes:

:set ft=unix
:%s/%\(\w\+\)%/$\1/g
:%s/set //ig
:%s/rem/#/ig
:%s/;/:/g
:%s/\\/\//g

There is always additional work to do, but these replaces do most of the tedious portion for me.