Bill Powell Is Alive [The Den]
{ Three Acres and a Penguin }

Vim syntax highlighting

updated: 2008 Sep 11 13:53 | begun: 2008 Sep 11, 13:28 Thu | tags: , ,

Syntax highlighting is the joy of text editing. Consider these two screenshots:

Screenshot: no syntax highlighting.

Screenshot: syntax highlighting.

(That's the xterm16 colorscheme with transparency turned on, using the mrxvt terminal with transparency on, a tint of #000020, and shading of 85. Background image: "View on Dubrovnik".)

Anyhow, as you can see, even the sparse syntax of Marxdown is far easier to read when the syntax is highlighted in different colors. You can even get things like bold highlighting, even though the underlying file is still clean, plain text. Mere asterisks let Vim know to color a word bold. No hidden codes are required; what you see is what's really in the file, but Vim can add colors. Vim isn't the first or only program out there that does syntax highlighting, of course. Any reputable text editor should do it.

My contributions

There many kinds of plain text in the world. This file uses Markdown syntax, but a PHP file would need PHP syntax, a CSS file would need CSS syntax, and so on. Each kind requires its own "syntax file", so Vim knows how to treat it.

Vim comes with quite a pile of syntax files, and the community has contributed even more at the Vim site under "Scripts". Every so often, however, I come across a kind of file that no one has needed syntax highlighting for yet. Fortunately, it's relatively straightforward to write your own syntax file. Here are the ones I've written, and uploaded.

You can find my Vim contributions here.

NoSQL and tab-separated files.

When you get hooked on plain text, you start trying to do everything with it. Tab-separated files are a simple way to store simple data. But I wanted each column to be a different color.

At the time, I was using a collection of shell scripts called NoSQL to access these tables, so I named the syntax file nosql.vim. I still use NoSQL for some old scripts, but lately I've needed the power of perl (DBI and DBI::AnyData) to access these files. DBI is a neat perl module because the syntax is the same whether you're talking to a MySQL database or a plain text TSV.

Anyhow, with this syntax file, columns appear in different colors. Keeps things sane.

get nosql.vim

DokuWiki

I've just this morning finally put up my syntax file for DokuWiki, the wiki I currently use for Wineskin Media. It's not from scratch, just a modification of a Wikipedia syntax file, but if you happen to use DokuWiki, you may find it useful.

get dokuwiki.vim

Make your own syntax file

It's really not so hard. Just open Vim, and

:h syntax

Actually, a better idea is to copy an existing syntax file and work from there. Just find one that isn't bewilderingly complicated. :)

Now available as bpalv.com!
Stop typing that amusing but neverending old
billpowellisalive-with-lots-of-tiny-l's-and-i's.com,
and try bpalv.com today!

Frequently Aggravating Questions

Helpful Pages

Feed: RSS 2.0 | Atom

Search

Tags/Categories/Ideas/Glue

(A supposedly easy and delightful way to navigate this site. Click one. It'll make sense soon.)

Archives

< September 2008 >
SuMoTuWeThFrSa
  1 2 3 4 5 6
7 8 910111213
14151617181920
21222324252627
282930    
2009 2008 2007 2006 2005 2004 2003 2001 2000 1999 1998 1997 1996

Rules

Do not link to dates or tags. They are capricious. They fear commitment.

Do not assume everything is tagged.

Do not boss around visitors to your web site.


[Powered by PyBloxsom]