Moving to Linux: Working with Text (Part 1)
As I highlighted in my last post, plain text is an excellent medium for writers to begin their process. Actually, in many cases, plain text is a perfectly acceptable format for writers to end their process in as well, but for now, let’s assume that you’ll be moving your words to a different format such as a word processor or, as I am, a blogging system.
But as a method for drafting your ideas, using text format is good for a few reasons, including:
- Portable: It’s not only easy to work with plain text on almost any platform, it’s also small and easy to move back and forth.
- Focused: When you work with text, your focus is on developing the ideas, not what font they will appear in or whether they will be ragged-aligned or justified. Also, most text editors have few bells and whistles to distract you.
However, most people used to working in a word processor are used to having a number of facilities at their disposal, including the following:
- Formatting (bold, italics, etc…)
- Spell checker
- Compare (with another document)
Let’s introduce a couple of tools that will allow you to perform some of the above functions on text files that you have.
I’ve recently discovered an excellent application that allows you to apply formatting to plain text. “
txt2tags” consists of two tools: text-based tags that you apply to your writing, and a tool that you run to transform your tagged text into other formats. You can be fairly productive with
txt2tags knowing only a couple of tags, as follows:
- Bolded text is enclosed in double asterisks: “**”
- Italicized text is enclosed in double slashes: “//”
- Underlined text is enclosed in double underscores: “__”
- Bulleted lists begin with a minus-sign and a space: “”- “”
- Numbered lists begin with a plus-sign and a space: “”+ “”
- Headers are enclosed in a number of equals signs equivalent to its level (e.g., and level-2 header would be enclosed by double-equal-signs, and be the same as an “<h2>” tag in HTML): “==”
As an example, I’ve drafted the two posts, “Moving to Linux: Tools for Writers” and this post, in the kate editor, using
txt2tags. This way I don’t have to worry about HTML tagging or style sheets while I’m drafting, yet I can easily convert this to HTML for posting into WordPress. To convert to HTML, you need only run a simple tool from the command line:
txt2tags -t html yourfile.txt
In this case, the addition of “-t html” tells the program to convert the file to “type HTML.” Once this is done, you should end up with a nicely formatted HTML document. For a fuller explanation of this tool, visit the excellent “cheat sheet” page at http://littlergirl.googlepages.com/txt2tagsCheatSheet.html.
In addition to this rudimentary formatting, you are also able to spell check the drafts you’ve done in text format using tools in Linux. The text editor you are using may have this function built-in; if it does, it is likely that it is using the
aspell library and programs, which are commonly installed by default on most Linux distributions. You need not look for one of these that has it built-in, however, as you are always able to run this program from the command line.
For those who are (still) unfamiliar with this concept, the command line in Linux is akin to DOS. Many consider the command line to be archaic and unnecessary. But there are many actions that are easier, more powerful, or both, when executed from the command line. This is true for Windows, but (at least) doubly so for Linux.
Using the aspell program is simple as creating a text file and entering the following command (on a side note, we’ll get around to introducing you to the command prompt, and enter shell commands, in a later post):
aspell check yourfile.txt
The program then enters the aspell interface, which will walk through any misspelled words in the file, and give you options to revise them. You select your action through key presses. For example, I fixed the misspelled word in the file below by pressing “1.”
aspell replaced the word, and saved a copy of the old file (with the misspelled word) with a “.bak” extension.
By adding the above two tools to a descent text editor, you will have a good start on a plain text writers toolkit for the Linux platform. In the next post, we’ll explore going beyond the current document and look at searching and comparing across two or more documents (or directories filled with documents) with a few more command-line tools.