Send As SMS

Writing On Your Palm

Your best source for information on writing, eBooks and handheld computing

Thursday, September 09, 2004

Vim with Vigor: Serious text editing for the Pocket PC

I'm a fiend for writing in plain text. I hate proprietary formats, and I spend as little time in Word on my PC or PocketWord on my Pocket PC (PPC) as I can. On the PPC, there are a number of text editors, but only one of them supports multiple documents and none of them support opening large documents. On my PC I use Vim, the vastly improved version of the Unix vi editor. Vim isn't an easy program to learn, and I'm no whiz at it, but it gets the job done. Now, after several tries, I have Vim version 6.0 working on my PPC as well. It handles files as big as I want and supports opening multiple file.

A fine fellow named Rainer Keuchel has ported a number of Unix programs to PocketPC, including Perl, Emacs, Vim, Apache and many others (http://www.rainer-keuchel.de/software.html). He has a small dll file that makes all the software work on WindowsCE devices, and environment variables required by Unix-like and Windows systems are handled via registry entries.

Vim isn't a small program by any means. All you're required to have to run Vim on the PPC is the executable (1.3M) and the celib.dll (148k). Of course, this minimal installation provides no menus, syntax highlighting or help. To use Vim most effectively you need to get the Vim 6.0 runtime files from www.vim.org and unzip them to your PC. A full installation Vim comes with megabytes and megabytes of runtime files, including a complete help system, syntax files, menu definitions, and more. You can use as many or as few of these files as you want on your PPC. I have the standard menu file (34K), a color definition file (3K), and the win32.vim file (3K) that makes Vim act a little more like a standard Windows application for highlighting, cutting, pasting and copying text. Finally I have my own personal configuration file, just a few hundred bytes in size. This file holds my preferences for margins, screen size, macros, key bindings, etc.

Vim is nothing like any standard DOS or Windows-based editor. The interface is hardly intuitive, and the learning curve is steep. Like the ancient Wordstar word processor, Vim was designed to keep the user's hands on the keyboard. Vim can be used with nothing more than standard typewriter keys plus the Control key and Escape key.

Vim generally operates in two modes -- command mode and insert (or append) mode. Insert mode is where text is entered; it has minimal editing capability. In command mode, keys and key combinations actually execute commands on the text. Command mode is invoked by hitting the Escape key; inset mode is invoked with one of several commands, including "i" (for "insert"). The dual-mode nature of Vim tends to drive beginners nuts. Fortunately, the modern, graphical versions of Vim, which include the PPC version, allow the use of pull-down menus for many commands.

So how does this all work on the space-restrained, portrait-mode PocketPC screen? Not too badly, though there are a few quirks.

First, the proper number of lines and columns must be configured. Vim is compiled with a handy right-side scrollbar, and with the standard Courier font I can see about 27 characters per line. In my config file I have the wrapmargin variable set to 0 so the text automatically wraps when it reaches the physical right edge of the screen.

Screen length is another story. Vim doesn't accomodate the Soft Input Panel; Fitaly, my SIP of choice, covers the bottom five lines of the Vim window. Vim simply doesn't automatically shrink the active window to accomodate it. Since Vim works great with an external keyboard, I've initially set it up to start with a full 16 lines of text; if I want to use Fitaly, I manually reset the screen size to 11 lines (I'm sure I can write a macro to do that, but I haven't tried it yet).

The Escape key is essential to using Vim, but the Escape key isn't well supported on the PPC. Though Fitaly has an Escape key in the customary place, the default soft keyboard has no Escape key, and my Dell folding keyboard uses a function key combination to invoke Escape. Kuechel took care of this by permanently substituting the Ctrl-C combination to act as the Escape key. This works well enough with Fitaly, and I've remapped two semi-colons tapped in quick succession to substitute for the Escape key for both my external keyboard and my PC keyboard. If I want to use the menus, I have to use a stylus.

Installation of Vim on the PPC is relatively easy, but not exactly straightforward. Start by copying the celib.dll file into the \Windows folder and vim.exe into any folder (I keep mine in the Axim's Builtin Storage). Things get complicated when establishing HOME and VIM folders and adding those locations to the device's registry. Keuchel provides an executable file and batch files that modify the Pocket PC registry (a PPC registry editor works as well). The example batch files show a lot of registry entries that cover more complex programs such as his port of Emacs (which I found to be much less stable on the Pocket PC than Vim).

Vim's environment is relatively simple; it requires a location for HOME and VIM folders. Instead of being designated through environment variables as on Unix/Linux and Windows, Keuchel creates a new key in the PPC's HKey_Local_Machine hive called "Environment." Choosing the location for HOME and VIM is the most confusing part of the setup, but once the right combination is entered into the Environment it's easy to add any of the standard Vim 6.0 runtime files, such as the help files, to the installation. I've set the HOME and VIM keys to \My Documents. The HOME key controls where my configuration file (_VIMRC) is located; the VIM key controls where runtime files live. I could easily change VIM to a folder on a storage card where I have more room to add runtime files I need.

I'm impressed with this port of VIM to WinCE. It's a powerful, versatile editor, as impressive in manipulating one or more plain text files as Textmaker is at manipulating formatted documents -- though Vim is considerably faster. It loads quickly, and I've opened two documents totalling nearly a megabyte in combination, each in their own window, and seen no falloff in performance. Vim itself is not a program to use without a willingness to make a committment to it -- but for those of us who won't be beholden to prioprietary formats for our deathless prose, it's the best answer for the Pocket PC.

1 Comments:

  • At 6:10 AM, Anonymous said…

    I wouldn't even try to use VIM on my Pocket PC although it may be different if I would own an external keyboard. VIM is a very efficient editor on a desktop PC where your fingers can rest on the keyboard without reaching for the mouse but on a Pocket PC it would drive me nuts.

     

Post a Comment

Links to this post:

Create a Link

<< Home