Minimalist tools for writers

482

Author: Dmitri Popov

Doing word processing without a dedicated word processor may seem like an absurd idea, but it actually makes a lot of sense, as long as you have the right set of writing tools — a solid text editor, the txt2tags utility, and Aspell spelling software.

Why would you want to dump your word processor? For a number of reasons:

  • Simplicity. With a text editor, there is nothing to distract you from the writing process: no context toolbars, no myriad of formatting options, no confusing menus — just you, an empty window, and a blinking cursor.
  • Concentrate on what you write, not how you write. OpenOffice.org Writer is a great word processor, but is it really your job to fiddle with paragraph styles, page formatting, table layout, image settings, and so on? Using the right text tools, you can concentrate on the actual writing, without worrying about the formatting.
  • Compatibility. The result of your labour is a plain text file, which is the most compatible file format out there. You won’t have to worry about whether your peers can open it in Word, or whether the text will be rendered correctly in some other obscure word processor.

Opting for a simple text editor can be tempting, but you might want to consider something more powerful. Vim is one such editor, and although it has a steep learning curve, once you’ve gotten to grips with it, the sky is the limit. If you are eager to start using Vim right away, use the vimtutor command to learn some Vim basics. Alternatively, this tutorial provides a good introduction to the editor’s essential features. There are also a few handy Vim cheatsheets and reference cards available on the Web to help you to keep tabs on Vim’s commands and options. Vim is available on Linux, Windows, and Mac OS X.

If you find Vim intimidating, you might want to opt for gVim instead; it features a graphical interface, menus, and buttons that will make you feel a bit more comfortable. There are also two Vim commands that can be immediately useful. The set lbr! command enables line wrap at word, which makes the text easier to manage, while :set mouse=a enables the mouse.

txt2tags

While Vim offers some powerful text editing tools, you may still need at least some basic formatting functionality, and you may also need a way to output the finished text file in different formats. This is where txt2tags comes in. txt2tags is a so-called document generator that can convert a text file into several formats, such as HTML, XHTML, SGML, LaTeX, and others. More importantly, txt2tags supports some basic markup and different configuration options that allow you to format your text file and do some other clever stuff. txt2tags’ markup resembles a wiki’s, and it is extremely easy to use. Although the list of markup tags supported by txt2tags is not as extensive as in an average wiki, it still includes the most used ones, such as titles, lists, links, images, and tables, as well as the so-called beautifiers (bold, italic, underline, etc.).

txt2tags also allows you to do some advanced stuff. For example, you can use macros in your text file; add the %%TOC line in the beginning of the text, and txt2tags replaces it with a table of contents in the output file. The %!include command can be used to include other text files into the current one, which allows you to divide long texts into several files and assemble them into a “master,” exactly as in OpenOffice.org Writer.

Another of text2tags’ nifty features is the ability to specify search and replace filters. Let’s say you are working on text that contains links to an online article. If the article’s URL changes, you have to correct every link in the text. With txt2tags, you can specify a search and replace filter that looks something like this: %!preproc: URL_ARTICLE "http://linktothearticle". Then, instead of writing the link itself, you use the specified URL_ARTICLE filter. If the URL changes, you have to correct it only once in the filter definition, and txt2tags will take care of the rest. txt2tags’ Web site provides extensive documentation that covers other clever features and options.

txt2tags is written in Python, and it’s available for different platforms. Many major Linux distributions contain txt2tags in their software repositories, so the software can easily be installed using your distro’s package manager (for example, Synaptic on Ubuntu and Adept on Kanotix). If you prefer to use the most recent version of txt2tags, you can download the source as well. Since txt2tags is a Python script, you don’t have to install or compile anything. Simply run it using the python txt2tags command (provided you have Python installed on your system).

Many text editors, including Vim, support syntax highlighting, and at txt2tags’ Web site you can download syntax files for different editors. To install and enable syntax highlighting in Vim, download the txt2tags.vim file, move it to the ~/.vim/syntax directory (you may need to create it if it doesn’t exist), then run the :syntax enable and :set syntax=txt2tags commands. Vim’s help provides a more detailed description of how to install and enable the syntax file (use the :help mysyntaxfile command).

To process the formatted text file, launch txt2tags using the txt2tags command. Most of txt2tags’ options are obvious, so you shouldn’t have problems figuring out how to configure and use the tool.

Aspell

A spellchecker is an indispensable utility for any writer. Most Linux distributions come with Aspell, a capable command-line spellchecking utility. Aspell is straightforward in use: the aspell check filename command will run spellcheck on the specified file using the default dictionary. Aspell can, of course, accept different options. For example, if you want to spellcheck a text in German, use the following command: aspell check -d de_DE filename. Using Windows? No problem: Aspell is available on Windows as well.

Other useful utilities

Every writer has his own tools of choice, but there are at least two utilities no writer should be without. wc is a tiny tool that counts lines, words, and characters in a specified text file. Just use the wc filename command to see the line, word, and number of bytes in the text file. To view the number of characters in the file, use the -c option: wc -c filename. You can also use this utility from within Vim; in the Command mode, enter the command as follows: !wc filename.

A decent language reference is essential no matter whether you write technical manuals or science fiction. And WordNet is a must-have language reference for any self-respecting writer. WordNet’s capabilities deserve an article of their own, so make sure to read the accompanying documentation to get the most out of this superb tool. WordNet is available for most major platforms, and you can run it from within Vim using the command !wn word (or !wnb word if you prefer to use the WordNet browser), where word is the word you want to look up.

If you are used to work in OpenOffice.org or any other graphical word processor, moving to text-based tools can be a bit of a cultural shock. But once you’ve learned to work the “text way,” you may never look back.

Dmitri Popov is a freelance writer whose articles have appeared in Russian, British, German, and Danish computer magazines.