Thursday, July 26, 2007

XEmacs - Still resisting the dark side

The other day, I had been contemplating changing to a fancier text editor.

Though I do little programming now, I still find a need for a programmer's editor as I will be frequently writing simple scripts or processing csv files created by Microsoft Excel or log files.

The other editor that I am familiar with is JEdit, which I had used for a brief period and have even contributed a macro. It had a good GUI, syntax highlighting for numerous programming languages and scripts, searching capability, plugin support, extensibility and so on. But, the one point it faltered was on the memory usage side. Just opening the editor took away a good 40MB of my scarce RAM. I guess it needed the memory to display those fancy icons and GUI controls.

XEmacs in comparison, ends up using less than 10MB and is way faster too.

Some indispensable commands

Over the course of time, I have started relying on a few commands, so useful that I use them almost daily. Your editor may have similar capabilities or you can hack them up on your own.

Smart Macros

XEmacs supports recording temporary macros. One technique that I use is, if I need to process a line, I record the activity. But in addition, I also record the key strokes that I use to get to the next line. This allows me to run the macro multiple times without manually placing the cursor on the next line.

The commands that I use for recording macros in XEmacs are start-kbd-macro and end-kbd-macro.

This technique in conjunction with XEmacs to add an universal-argument (repeat count) allows me to process text files in a jiffy.

Regular Expressions

Regular expressions are the most useful feature used to search and replace text. Two features that I use most are keep-lines and flush-lines. Both take a regular expression and keeps or filters out matching lines in the buffer or a selected region. This is particularly useful when you are processing CSV files or logs to quickly glean out useful text and remove the unwanted.

Most of the editors that sport good UIs may support some of the capability, but loose out on one of the most needed capability: The ability to quickly start and use less RAM. And that's why I still stick with (X)Emacs.

No comments: