The Hessling Editor (the) - Getting Started

saltair
  4 years ago
  0

The Hessling Editor (the) – Getting Started

The Hessling Editor is an extremely powerful text mode editor based upon the IBM VM/CMS or z/VM (Mainframe) editor: XEDIT. It's a great piece of work by Mark Hessling, but I find the default configuration to be somewhat confusing  e.g. standard keys like the arrow keys don't work like they should.

 

Configuration with a Profile

To get started in XEDIT mode, enter the following at the editor command line:

set compat xedit xedit xedit

You won't want to do this each time you invoke the editor, so to avoid this you need to create a profile. This is a file with the name ".therc" that you can place in your home directory e.g. /home/xyz/.therc (assuming xyz is your user name). Alternatively you can place it in a shared directory if you want it to be available to multiple users.

The profile can contain a variety of editor commands that are documented in the reference manual. I find the following to be useful as a minimum:

/* norexx */

'set compat xedit xedit xedit'

'set case mixed ignore ignore ignore mixed mixed'

'set numb on' /* provide line numbers in the prefix area */

 

Once you've created your profile, then it will automatically be executed when you start the editor e.g. the datafile.txt

Unfortunately the clever command name "the" lends itself to confusion and so you may want to rename it or create an alias for it.


A Slightly More Advanced Profile

The following has a few more commands that explicitly set up some function keys for certain actions. It also adds a reserved information line to the top of the edit window. Lastly it tells the editor to use this profile for each file when multiple files are being edited in a chain or recursively.

 

/* norexx */

'set compat xedit xedit xedit'

'set case mixed ignore ignore ignore mixed mixed'

'set numb on'

'set coloring off'

'set reserved 1 Function Keys: f2=add line, f3=qquit, f5=spltjoin, f12=dir edit'

'define f2 sos lineadd'

'define f3 qquit'

'define f5 spltjoin' /* split or join at cursor focus */

'define f12 sos edit' /* edit file from directory list' */

'set reprofile on' /* use this profile for each file in a chain */

 

Highlights

The editor is extremely powerful and contains many features for power users that may be rather obscure to those not familiar with XEDIT. Commands like "ALL" allow you to filter content in very useful ways. Macros can be used to customize and extend the capabilities of the editor. Need a command not baked into the editor like something to manipulate columns of text or delete duplicate lines? Just roll your own. Want to mark lines of text for deletion? Use the prefix area. Want to see the hexadecimal equivalent of a line? Use the HEXSHOW command. Want to sort the file? Use the SORT command. My intent here is to give you a sense of the capabilities of the editor rather than be an extensive tutorial. Some of IBM's documentation might be a good place to start if you're unfamiliar with XEDIT.

 

Macros

The editor is highly programmable and you can do amazing things with macros. A few macros are distributed with the editor. These are written using the REXX language (the REXX/REGINA interpreter is distributed with the editor). The editor environment is readily accessible via macros as is the os environment which provides for some interesting and very powerful capabilities. Mark's documentation refers to a demo capability "demo.the" which is bundled with the software, but it doesn't appear to work correctly with the distribution as installed by the software manager. I haven't had time to figure out what the problem is. There are some other examples that get installed in the /usr/share/THE directoryt although I got mixed results when I tried them so I'm not sure what's going on. One example that you can try is the "append" macro to add a string to one or more lines in a file.

To enable the common shared macros, issue the following editor command (you might want to add this to your profile):

set macropath /usr/share/THE

Then, while editing a file you can, for example, use the append macro to append the string "closed" to each line in the file that contains the words "sat" or "sun"

e.g. enter the following sequence of commands on the editor command line:

top

all /sat/ | /sun/

append * closed


Note that these commands could also be placed in their own command file if this was a sequence of operations that you wanted to repeat, say, on different text files. You could then have your own "weekend-update" command.

The source code for the append macro can be viewed as: /usr/share/THE/append.the

Macro writing with the REXX language, however, is a huge topic and beyond the scope of this article. Nonetheless, hopefully this will give you a sense of what is possible.    You can manipulate file contents in just about any way conceivable.

 

Invoking the Editor

Typically invoke as : the <filename>    e.g. the datafile.txt

You may also just issue the command “the” in which case the editor will open and the “file” contents will be a directory list. Providing you have assigned a function key as per the preceding more advanced profile (e.g. f12 is assigned to the sos edit command) , then you may simply position the cursor to the directory entry of choice and hit f12 to open it.

There are several command line flags that can be specified when invoking the editor. To see what these are, invoke with the help flag  e.g.  the -h

For example, if you want to edit a file with very long lines of text you can override the default line width when you invoke the editor

e.g. the -w 30000 datafile.txt

 If you want to create an icon on the desktop for the editor, then you will need to create a launcher (right click on the desktop to get started) . Fill out the launcher properties and remember to check the box that says “Launch in Terminal”. Once you have a desktop icon, you can then “drag and drop” a file into the editor. If you just double click on the icon, it will open with a directory list.

Further Reading

Mark's documentation is at: hessling-editor.sourceforge.net. IBM also has a bunch of XEDIT documentation - search online for: z/VM Xedit Tutorial or z/VM Xedit User Guide. Note that the Hessling Editor is based upon XEDIT and is very well done, but is not an exact clone.