![]()
Linux Inside: Unix editors and web page authoring
by Gene Wilburn
(The Computer Paper, September 1999. Copyright © Wilburn Communications Ltd. All rights reserved)
One of the first questions I get asked when a Windows or Mac user discovers I'm running Linux is "what do you use it for?" There are so many answers to this that I'm sometimes stumped for a quick reply.
How do I quickly explain that I use Linux as a file and print server using Samba, as a development environment for C, Perl and shell scripts, and as a writing platform for books and articles? That it is also my mailhub, my newsgroup server and my gateway to the Internet via IP Masquerading? And that this barely scratches the surface?
I've finally decided that the only simple answer is "for all the same things you use Windows or a Mac for, plus some really handy server functions." No point in overloading them with details they might not understand or appreciate.
One thing many of them can appreciate, however, is using Linux as a server running Apache. Apache is the most widely used web server on the Internet and developing web sites on a Linux platform provides you with a professional-level WWW development environment. Moreover, you can set up a Linux/Apache server by recycling that old 386 or 486 in the corner.
Some Windows and Mac users are happy to have a Linux/Apache server on their LAN so they can continue to use the web authoring tools they're familiar with while still reaping the benefits of working with Apache.
Others have made a complete switch to using Linux as their workstation platform, using native Linux web authoring tools. There's a range of good tools for creating web pages in Linux but one thing you can bet on: the majority of authors who create web pages with Linux use a text editor.
Why a text editor? Because traditional Unix text editors are editors on steroids. They evolved in the golden age of text processing, before the world went nuts with bloated, incompatible binary word-processing files. Newcomers often find the Unix editors daunting and shy away from them. That's a mistake.
One of the biggest favours you can do yourself as a new Linux user is learning the basics of vi and Emacs. Yes, they're kinda weird, in that they have some odd keystrokes to memorize. Just memorize them. It's like learning to swim. Once you've done it, water suddenly takes on intriguing new potential.
vi
The most ubiquitous Unix editor is vi (pronounced VEE-EYE), one of the oldest and most venerable editors around. You'll find it on every Linux or Unix system you ever encounter (and there are even ports to DOS and Windows). It was developed by Bill Joy at Berkeley at a time when programmers used terminals rather than PCs to interact with a Unix host computer. Consequently vi makes no assumptions about extra keys, such as PgUp, Home, End, F1, etc. You can perform nearly every vi operation directly from the standard typing part of the keyboard.
The reason you can do this is because vi has two modes: command and edit. You shift gears (by hitting the ESC key) to get from insert mode to command mode. By today's standards the vi keystrokes seem arcane, but one of the things you come to realize is how efficient vi is once you know it. There are people, to this day, who write entire books using the vi editor. Learning vi is a rite of passage. If you don't know it, you're never quite a real Linux user.
In the Linux world, there are several modernized versions of vi to choose from: Vile, Elvis, and Vim are three of the more popular. Vim, which stands for Vi Improved, is the default vi editor of many distributions.
Vi is a very light, fast editor--an embodiment of the "small is beautiful" Unix tool mindset. Despite its small size, it is amazingly capable. It offers very powerful search and replace functions based on regular expressions. Vim, my favourite vi, offers some updated features I find useful for authoring HTML pages. For blocks of text, such as paragraphs, it has a built-in reformatter that allows you to easily reformat lines.
It also has a colour syntax hilighting mode (:syn on) that makes HTML codes stand out, helping you catch syntax errors. There is nothing particularly fancy about vi, but it gets the job done without any fuss and it is very fast. You can also write your own vi macros for specialized functions.
Emacs
Emacs is the diametric opposite of vi. It is a large, complex text editor with a built-in version of the LISP programming language. Written by Richard Stallman, founder of the Free Software Foundation, Emacs has been around for some time--GNU Emacs was the original program offered by the FSF GNU Project in 1984.
Being programmable, Emacs has a number of specialty modes that have been developed for it. There's a mode for C, Perl, text, and there's an HTML/SGML mode. (There's an even more sophisticated PSGML mode you may wish to track down if you decide to stick with Emacs for web-page authoring.)
Emacs, too, contains a number of keystrokes that evolved from the days of terminals connected to hosts. It combines Ctrl and Alt combinations for a rich medley of features. Quite frankly, Emacs as a terminal-based editor is challenging to learn because of the very large number of options. It cries out for pull-down menus and mouse support, which it gets in X Window. When you run the X Window version of Emacs it suddenly feels very modern and (mostly) intuitive.
When you open or edit a file that ends in .html, Emacs automatically loads SGML mode and two new items appear in the Emacs menu bar: HTML and SGML. The HTML menu provides a number of frequently used HTML tags that Emacs will insert into the text. Emacs also visually tracks opening and closing angle brackets, square brackets, parentheses and braces, providing visual alerts for unmatched pairs. A parser, called from the SGML menu, provides HTML validation checking. As with Vim, you can switch on colour syntax hilighting.
In addition, Emacs directly incorporates a Linux feature I can't live without, whether I'm editing web pages, programs, or articles. It's called "version control". Every time I make a significant change to a file I check it into the RCS (revision control system) library and my file gets updated with a new version number. All my previous versions are kept in a versioning file and I can revert to any previous version at any time. All this can be done via clickable Emacs menu options.
Emacs is more than just an editor. You can use it to read your mail, read newsgroups, play chess, and even surf the net. If you develop a taste for it, you may end up using it for nearly everything. On an Internet newsgroup I once saw a tagline that declared "Emacs is my operating system, Linux is my device driver." HTML page creation is just another of the very good reasons to try out Emacs.
Netscape Composer
Okay, you say, but weird text editors are not for me. Harrumph! I'll let you off gently, with the reminder that weirdness is in the eye of the beholder. The next option is one that lots of folks in the Windows world seem to like. It's called Netscape Composer and is part of Netscape Communicator (Linux version, natch).
Netscape Composer is the Kellogg's Cornflakes of HTML authoring tools. It provides a few essential nutrients and, though boring, is not totally unpalatable. It is virtually identical to the Windows version and allows you to create pages in WYSIWYG mode. Netscape is also found on nearly every Linux workstation, so it's a tool that's usually available.
My main objection to Composer is that the code it produces is ugly, with all the HTML tags in upper case (Unix is a lower-case culture) and some of the coding is questionable. Netscape-produced pages often don't clear a good Linux HTML validator such as weblint. Still, it's an option for those who want something like they use in Windows and anything beats using FrontPage.
Amaya
If you subscribe to the fashionable, but dubious, school of thought that hand coding HTML pages is a thing of the past and wish for something more upscale, look no further than Amaya (see www.w3.org/Amaya/). This open-source program is worlds apart from text editors and limited WYSIWYG editors such as Netscape Composer.
Amaya is the funky WYSIWYG editor/browser from W3C, the folks who set the international standards for HTML. It is freely available in both Unix and Windows versions. Several Linux vendors offer it as a downloadable RPM and SuSE Linux includes it on its distribution CDs.
The current version of Amaya (2.0) supports HTML4, MathML (a proposed standard for marking up and displaying mathematical expressions and formulae on the web), CSS (cascading style sheets), and HTTP (direct publishing to a web site).
Moreover, Amaya has a "make book" feature that allows you to structure separate web-based chapters in such a way that they can be combined into a single document for printing purposes--a long sought-after feature for anyone trying to use the web as a documentation vehicle.
Amaya flips between editor and browser mode with the click of a mouse. It sports a button bar with icons for the most frequently performed HTML operations and offers support for everything from fonts to tables to image mapping.
Amaya does not display HTML source code. Instead it provides a "Show Structure" view that displays a striking presentation of a page's HTML structure.
Amaya is one of those products that, combined with a graphical desktop manager such as KDE, makes Linux a feasible alternative to Windows and Macintosh for web authors who do not share the Unix programmer's passion for traditional text editors, however powerful.
In overall feel, it is similar to the Windows Dreamweaver product. And Amaya, bless its developers, inserts HTML codes in lower case, the way the web gods intended. This is one sweetheart of a product, though it will never displace vi or Emacs for us diehards.
Gene Wilburn (gene@wilburn.ca) is a Toronto-based IT manager, musician and writer who operates a small farm of Linux servers.
-30-