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

tagged with: linux

Vim syntax highlighting

begun: 2008 Sep 11, 13:28 Thu | updated: 2008 Sep 11 13:53 | 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. :)

Fuzzy Time (and an updating bash prompt)

begun: 2008 Aug 15, 9:50 Fri | updated: 2008 Aug 15 10:37 | tags: ,

And what better way to spend free time than to take time to blog about time? About altering your very conception of time. In short, about fuzzy time.   more »

The Dangers of Linux

begun: 2008 Jul 30, 8:25 Wed | updated: 2008 Jul 30 06:42 | tags: ,

Linux Addiction?

I'll be surprised if this comic isn't all over the place in a few hours, but you may as well see it here.

COMIC: Parents, talk to your kids about Linux...befory somebody else does.

Of course, writing drivers for hardware is a wee bit easier when the companies actually talk to you. The laugh for me might not be what the author intends; not because peripherals are always broken on Linux (they aren't) but because the power of Linux makes the newbie redefine "broken" so rapidly. In Windows, "broken" used to mean that the computer crashed more than once or twice a day. In Linux, a "broken" Xorg might just mean that some default setting in the distribution prevents me from running multiple instances at the same time. "Broken" starts to mean, "it won't do exactly what I'm imagining it could." Linux can become the most addicting computer game ever devised.

Wordpress Users: Spam in your Source!

begun: 2007 Dec 04, 19:03 Tue | updated: 2007 Dec 04 17:03 | tags:

If you or someone (else) you love uses WordPress, go to your site right now and view the source. Hopefully, you won't see what I did.   more »

Spreading the Laptop Virus?

begun: 2007 Dec 01, 16:46 Sat | updated: 2007 Dec 01 14:46 | tags: ,

Before the XO, all they could do together was climb trees, shout in each other's faces, laugh their heads off, and (presuming a poverty of cars) run wild through the streets. Now, at last, comes a bountiful wealth of experience.   more »

How to convert HTML tags in XML to HTML

begun: 2007 Sep 29, 12:17 Sat | updated: 2007 Sep 29 10:17 | tags:

I could add tags for categories, date, and so on, but the first thing I’d need to do would be to make sure that my new XML would translate properly back into HTML.

  more »

Free Software from a Typesetter’s View

begun: 2007 Sep 28, 03:50 Fri | updated: 2007 Sep 28 01:50 | tags:

Rather than attempt to support every version of every proprietary application in use, excellent as it may be, I simply use software which any client can always download for free.

  more »

VimOutliner (and a tweak to use colorschemes)

begun: 2007 Jan 24, 03:36 Wed | updated: 2007 Jan 24 01:36 | tags: , ,

So far, you’ve probably seen these features in other outliners too. What the picture doesn’t show is how fast it works.

  more »

Linux and the Catholic Church

begun: 2006 Oct 19, 14:35 Thu | updated: 2006 Oct 19 12:35 | tags: , ,

Should the Catholic Church use Linux? On principle?

  more »

A Hymn to Vim

begun: 2005 Apr 23, 00:00 Sat | updated: 2005 Apr 22 22:00 | tags: , ,

My favorite way to write: Vim.

  more »

Linux What?

begun: 2004 Oct 25, 00:00 Mon | updated: 2004 Oct 24 22:00 | tags:

Sick of M$ Word? Try OpenOffice (free). Torn between pirating Photoshop or pawning your piano? Try the Gimp (free). Let’s see, how many thousands of dollars have we saved so far?

  more »

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    
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]