Home Page


Vim, AFT and Text Processing

I use Vim as my text editor. I have no particular advocacy for one editor or another -- whatever gets the job done. I still use Jed, Xemacs, and Emacs, as the spirit moves me (I started with MicroEmacs way back in the 80's on DOS systems, after losing interest in the various WordStar-type of things around).

However, once Vim gets into your autonomic reflexes, you find yourself doing incredible things, without thinking, that make other editors seem like a straight-jacket (at an elementary level: "Fv~A", to fix the capitalization on the word "vim", and then go back to typing). It is great for touch typists and rewards the learning curve with many efficiencies. You can also avoid using the mouse, which I find slows me down. However, many find the modal nature of the editor annoying. Having grown up with "vi", it is second-nature to me. It helps to buy a keyboard that has the "Escape" key next to the "1", instead of miles away (along with the function keys), as do most of these supposedly efficient, modern keyboards. I still find uses for WYSIWYG editors, but the vast majority of my typing these days is in Vim. Vim can seem strange, but there is a coherent logic and efficiency to the choice of keys that becomes apparent after some sweat-equity! The old becomes new again.

AFT stands for "Almost Free Text", authored by Todd Coram. It is a document preparation system inspired by the Wiki-Wiki Site editor. AFT uses Perl 5.005 or greater and is very easy to install. You can find out more at

Both AFT and Vim can be made to work on Windows systems. However, the lack of access to Unix tools restricts some of the possibilities (though, check on the Cygnus tool set). Still, it is a powerful combination, but with a learning curve.

AFT has a philosophy similar to systems such as TeX, but without all the intrusive markup. Indeed, AFT source documents are often themselves suitable for the reader. AFT is intended for simple output in such formats as HTML. There are a few small "gotchas" as you learn the system that are not explained in the manual, but by and large it is very easy to use. If you want to bang out a lot of text without worrying about the style of your document, and have straight-forward formatting needs, consider AFT. If you are doing program documentation, consider AFT. It can be very convenient, too, if you need to output several document types. Also, because it is plain text, all the various Unix tools are at your disposal to automate document production and change in almost limitless, completely flexible ways, that WYSIWYG cannot begin to match. The intent of tools like AFT is to allow you to concentrate on what you have to say, and the structure, without worrying about the style details. In some respects, this is similar to style sheets in a WYSIWYG word processor, but note the pros and cons of both systems, depending on your skill level, knowledge, and the complexity of your documents and revisions. Again, a WYSIWYG word-processor such as Microsoft Word has its rightful place, but many people are not aware that sometimes orders of magnitude of work can be saved, depending on their situation and requirements.

If you are using AFT for HTML, you can always pass in HTML instructions via a pragma facility. Although less maintainable, you can edit the HTML in a WYSIWYG editor, or by hand, to "guss it up" a bit. Better yet, keep it simple. I will avoid dwelling on HTML incompatibilities and browser wars....

If your needs are more complex, consider things like Tex, LaTeX, or DocBook. (I must mention Lout and Thot, these two being much less common -- in many ways Lout can be considered technically better then TeX, but it has a smaller mindshare). All of these are particularly convenient if you are working on complex documents that have internal dependencies (like a book or a scientific/mathematical paper). You can also explore the Linux Documentation Project for various tools that Open Source and GPL programmers use to produce project documentation, such as LinuxDoc.

Here is some more advice:

Vim Scripts

Apparently, I had too much time on my hands last week. I learned the basics of producing a syntax file in Vim 5.6 (I imagine it should work in Vim 6.0). Much thanks to Vi IMproved -- Vim, by Steve Oualline.

There are some limitations to the file, notably, that contained elements will only be colored according to the containing element. Also, tabstops are required to be set to 3. This can be changed, but I'm hoping someone can point out a better way of doing things to accommodate different settings. Basically, this file is good enough for me, and I offer it in the hopes that others may find it useful (with a little adjustment for tabstops).

Please note that most programming editors, such as Vim, have syntax colouring methods that revolve around the needs of programming languages. That makes a free-format system like AFT a bit of a pain to work with. The main caveat is that coloured elements do not necessarily agree with what AFT thinks they are. They are just that, elements that are coloured. Without writing an AFT parser in Vim, some limitations will naturally exist. Still, there is room for improvement. Further notes are made in the source itself. Please email me if you have something to contribute. Credit will be given, especially to syntax gurus!

One of these days, I plan to upgrade to Vim 6.0, and at that time will add support so that AFT-style sections can be accommodated with Vim's folds.

The syntax file above, and the two RC files below, are completely independent.

Right now, the above two files only contain a few abbreviations.


Home Page


This document was generated using AFT v5.0792 and Vim