Xed: A programmer's text editor

User's Guide

Introduction

Xed is a programmer's text editor for use on UNIX computers with the X Window System. It is designed to be small, fast, simple to use, and customizable. It is not intended to replace word processors or desktop publishing systems; rather it provides a rudimentary tool for programmers and system administrators that avoids the cumbersome and primitive character of alternatives such as emacs and vi. Xed has the advantage that it can deal effectively with Macintosh, MS-DOS, and UNIX text files, and can properly display tabbed text. Xed is distributed freely, with all source and executable code.

This program was written beginning in the early 1990's because I didn't want to learn emacs and vi was too hard to move around in. I have been using it every day since then, but I do not expect anybody else to ever use it.

Getting in:

Users may specify the input files on the command line. For example, xed temp.dat causes the editor to load the file temp.dat. If you specify no file on the command line, the editor will prompt you for a file name when you save the file. If you specify more than one file, all of the files will be loaded at the same time, and you can switch from one file to another, copying and moving blocks of lines among files as well as within files.

Getting out:

To exit, saving your file, press F1 or Alt-X. To quit without saving, press F2 or Alt-Q.

X Windows resources

X-windows resources may be specified in an app-defaults file (typically stored in /usr/lib/X11/app-defaults, a .Xdefaults file, or on the command line. Most standard resource specifications are interpreted by xed. In addition, xed recognizes the resources backup, keymap, status_fg, and status_bg.

The backup resource, if specified, causes xed to make a copy of the current on-disk version of the file, naming the copy filename.bak.

The keymap resource should specify a pathname for a file containing the key definitions, if other than the default key bindings are to be used. Additional instructions for changing the key bindings are given below.

The status_fg and status_bg resources, if specified, govern the foreground and background colors, respectively, of the status line and menus. These default to the background and foreground colors, respectively, of the main window, so that by default, the status line and menu colors will be the reverse of the main window's foreground and background colors.

Getting around:

The top line of the screen or window is used as a status line, and indicates the line in the file that the cursor is on, the column that the cursor is on, the insert state, the autoindent state, the tab width, and the file name. If the file name is preceded by a plus sign, changes have been made to the file. An example is shown below:
L  10  C   12  IA4  +foo.dat
This status line indicates that the cursor is on column 12 of line 10 of the file foo.dat, that the file has been modified i.e. that the copy in memory has changes that have not yet been saved to disk. Insert is active, as is autoindent. Tabs expand to 4 spaces. If you do not have write permission for the file, the plus sign will not appear; instead, the designation (Read Only) will precede the file name. If the file has been loaded as binary data, the designation (binary) will appear as well.
example editing window

If you click the mouse anywhere in the window, the cursor moves to the character position nearest the point where the mouse button was pressed.

Users should note that xed considers tab width to be a variable. The default tab width is 4 spaces. Many documents created in the UNIX world assume that tabs are eight spaces, so you can alter the tab width by pressing Ctrl-Tab. Note also that tab characters are initially visible in xed, and you cannot place the cursor onto any of the spaces that result from tab expansion. By pressing Ctrl-v, you can toggle the tab visibility through three states, an invisible state, a minimally visible state (the default), and a maximally visible state in which one can distinguish the tab fill characters (which fill the space between a tab and the following text) from true spaces.

Menu

Xed actions may be chosen by pressing appropriate function keys or by selecting items from menus. Menus are ordinarily hidden and are activated by a keystroke (Escape). Clicking on the status line also brings up the menus. Once activated, the menus can be browsed by using the arrow keys and the Home, and End keys. To select a menu item, highlight it using the arrow keys and press Enter or Return. Menu items can also be selected using the mouse.
example showing menu selected

Xed has a rudimentary help facility associated with its menus. To find out what keystrokes can be used to produce the effect of a particular menu selection, highlight a menu item and press the question mark. Xed will print on the xterm from which it was launched brief descriptions of all keystrokes that produce this action. Note that these descriptions will refer to an "Alt" modifier key that may not be present on your system. This really refers to the Mod1 modifier key.

Getting from one file to another:

Xed is capable of editing any number of files at a time. It keeps a circular linked list of files you are editing. To switch from one file to another, use Alt-> (that's the Alt key followed by the "greater than" sign) to move to the next file, or Alt-< for the previous file in the list. To edit another file in addition to those you specified on the command line, press Alt-E. You are prompted for the file name, and the file is subsequently loaded and added to the linked list of files.

You can enter a directory specification at the "Edit file:" prompt. If xed determines that the name you entered is a directory, it presents you with a list of files in that directory. Use the arrow keys to select a file from the list; if you choose another directory (identified with a trailing slash character), the corresponding list will appear.

example showing file selection

Editing binary files:

Xed has the ability to read and write binary files. Editing binary files is somewhat problematic, of course, and the strategy xed uses may not be satisfactory for some purposes. At present, the only way to specify that a file be interpreted as binary is to open the file from within the editor (not on the command line), following its name with a space and the letters -b.

When asked to read a file as binary data, xed creates a hexadecimal display; each line has sixteen bytes displayed as hexadecimal numbers, followed by a tab, a pound sign (#), and the ASCII equivalents of those sixteen bytes. Non-printable characters are displayed in the ASCII section as periods.

You can edit this hexadecimal display as you like; no special binary editing mode exists. When asked to save the file, however, xed will look through each line, converting pairs of hexadecimal digits back to binary bytes and writing them to the output file. When it encounters a character that is neither a hexadecimal digit nor a whitespace (blank or tab), it skips to the beginning of the next line and continues the conversion.
example showing binary file editing

Key assignments:

One of the main goals for xed was to make keys do what they look like they should do. For example, the Page Down key should page down, the Delete key should delete, and the Home key should move the cursor towards the beginning of the line or file.

Since there aren't keys specifically made for many important functions, many keys have arbitrary assignments. These are intended to mimic other packages (e.g. Qedit and WordStar on MS-DOS systems) but do so in only a limited fashion.

To change what a particular key does, you'll need to modify a simple table in the source code and recompile the program.

A more dynamic configuration occurs under X Windows; if the X display name does not begin with a colon (i.e. if xed is running on another machine), xed looks for a file in the user's home directory named xed.hostname where hostname is the name of the host on which the window is to be displayed. This file, if it exists, is assumed to be the binary output of the configuration program xed_config (see below). Its contents replace the default keymap table.

For those keys that are significant when modified using Shift, Ctrl or Alt, the modified action is either the same or is complementary to the action of the unmodified key. For example, the left arrow key moves the cursor left one space, while Ctrl-Left moves the cursor left one word. Similarly, the Home key moves the cursor to the beginning of the line, and Ctrl-Home moves it to the beginning of the file.

Modifying the key assignments:

In the X Windows version if you select the action KEY_ADD_KEYS, you are prompted for the name of a text file containing key definitions. Xed reads the file and merges the definitions with the existing keymap table, so that key combinations that already have a function will be redefined to reflect the new meaning, and those that were previously unassigned will be added to the keymap.

Printing

Xed has the ability to create a PostScript representation of the current file and transmit the PostScript file to a printer.

Items under the Print menu control the layout of the printed page.

Moving, copying, and deleting blocks of text:

Block operations are restricted to whole lines. You cannot move or copy a marked block when the cursor is inside the block. This limitation is significantly different than most professional text editors. It should really be improved, but I have learned to live with it.

If the block starts and ends on the same line, and the end follows the start, the intervening text is copied to the paste buffer, and can be inserted elsewhere by pressing Ctrl-p.

Balancing parenthetical expressions:

KEY_FIND_MATCH operates only if the character at the cursor position is a parenthesis, bracket, brace, the greater-than or less-than sign. It causes the editor to search for the opposite symbol. For example, with the cursor on the left parenthesis, pressing Ctrl-F3 causes the cursor to move to the matching right parenthesis. Consider the following example.
if (((c = getc(stdin)) != EOF) && ord[c] != 'a') {
   abc        d     dc       b                 a
Here matching letters appear on the line below matching parentheses. KEY_FIND_MATCH operates either forward or backward, depending on whether the character at the cursor position is a left-symbol (one of (, [, {, or <) or the corresponding right-symbol ( respectively, ), ], }, or >).

Search and replace:

The search and replace facilities are simplistic. You specify a search target by using Ctrl-f (for a forward search) or Alt-f (reverse). To find the next occurrence, type Ctrl-L. To replace, use Alt-p to set the text in the paste buffer, then use Ctrl-r to replace only once, or Alt-r to replace every occurrence from the cursor position to the end of the file.

Note that the text pasting operation respects the insert state. If Insert is off (no 'I' appears in the status line), the paste operation overwrites characters already in the line. This effect occurs both when KEY_PASTE is invoked directly (with Ctrl-p) and during replace operations.

Autoindent:

Autoindent is likely to be unfamiliar to nonprogrammers. This function causes an initial string of whitespaces to be inserted whenever a KEY_NEW_LINE is executed; the initial string of whitespaces is taken from the preceding line. Whitespace includes blanks and tabs.

Line breaking:

Xed provides a facility for breaking a long line into a paragraph. Alt-B enables you to set the right margin, which is 76 characters by default. By pressing Ctrl-B, you can break the current line into separate lines, each ending to the left of the right margin. Words will not be split during this operation.

Character conversion:

The current character (i.e. the character that the cursor is on) can be converted as follows:
to upper case		Alt-1
to lower case		Alt-2
switch case		Alt-3
to hexadecimal		Ctrl-F2
from hexadecimal	Ctrl-F4

Retrieving deleted lines

Xed puts lines deleted through KEY_DEL_LINE (Ctrl-y) into a stack, and the most recently deleted line can be inserted through KEY_UNDEL_LINE (Ctrl-u). The stack is of unlimited size, because it is implemented as a linked list. In edit.c there are commented lines that would cause deleted blocks to be appended to the stack of deleted lines; because this policy could cause memory to become crowded it was not enabled, though users can change that decision by modifying edit.c and recompiling.

Xed actions

The following list gives short descriptions of the actions that xed is capable of performing. To find the details of how an action is performed, find its entry in the switch table of function process_key() of source file xed.c. The action names themselves are used (in the UNIX environment) to build an alternate keymap description file; the procedure is described under "Using xed_config" below.
Action code Function description
KEY_SET_TAB_WIDTHAllows user to specify new tab width
KEY_FIND_MATCHMoves cursor to matching symbol
KEY_WRITE_BLOCKWrite marked block to a new file
KEY_DEL_BLOCKDelete the marked block
KEY_SEARCH_BACKWARDSpecify a string and find its previous occurrence
KEY_SEARCH_FORWARDSpecify a string and find its next occurrence
KEY_FIND_NEXTContinue the last search
KEY_FIND_NEXT_NONPRINTABLEMove to the next non-printing character
KEY_SET_PASTE_TEXTEnter text into the paste buffer
KEY_PASTEInsert the contents of the paste buffer at the cursor position
KEY_REPLACE_ALLReplace all subsequent occurrences of the search string with the paste text
KEY_REPLACE_ONCEReplace the next occurrence of the search string with the text in the paste buffer
KEY_DEL_SPACE_TO_RIGHTDelete whitespace (blanks and tabs) to the right of the cursor
KEY_TOGGLE_TAB_VISIBILITYChange the appearance of tab characters and tab fill characters
KEY_DEL_LINEDelete the current line
KEY_UNDEL LINEUndelete a line (insert the most recently deleted line at the cursor position)
KEY_WORD_LEFTMove to the beginning of the previous word
KEY_WORD_RIGHTMove to the beginning of the next word
KEY_MOVE_TO_TOP_OF_SCREENMove to the top line displayed (not the status line)
KEY_MOVE_TO_BOTTOM_OF_SCREENMove to the bottom line displayed
KEY_MOVE_TO_BEG_OF_FILEMove to the first line in the file
KEY_MOVE_TO_END_OF_FILEMove to the last line in the file
KEY_SCROLL_UPScroll the file up, keeping the cursor on the same line
KEY_SCROLL_DOWNScroll the file down, keeping the cursor on the same line
KEY_TOGGLE_AUTOINDENTIf autoindent is active, turn it off, and vice versa.
KEY_DEL_TO_BEG_OF_LINEDelete all characters to the left of the cursor on the current line
KEY_DEL_TO_END_OF_LINEDelete all characters to the right on the current line, including the cursor position
KEY_IGNOREIgnore this keystroke
KEY_SAVE_AND_EXITWrite the current file to disk and remove it from memory
KEY_QUITRemove the current file from memory; prompt if it has changed
KEY_QUIT_ALLForgetting all changes, return to the system.
KEY_SAVE_FILEWrite the current file to disk
KEY_GO_TO_LINEMove to a specified line (specify by number)
KEY_COPY_BLOCKInsert a copy of the marked block before the current line
KEY_MOVE_BLOCKInsert the marked block before the current line
KEY_MARK_BLOCK_STARTSet the beginning of the marked block
KEY_MARK_BLOCK_ENDSet the end of the marked block
KEY_HIDE_BLOCKUnmark the current marked block
KEY_DUP_LINEDuplicate the current line
KEY_DUP_CHARDuplicate the character at the cursor position
KEY_MOVE_LEFTMove one character to the left
KEY_MOVE_RIGHTMove one character to the right
KEY_MOVE_UPMove to the preceding line
KEY_MOVE_DOWNMove to the following line
KEY_MOVE_TO_BEG_OF_LINEMove to the first character of the current line
KEY_MOVE_TO_END_OF_LINEMove to the space following the last character in the current line
KEY_PAGE_UPMove up about one screenfull of lines
KEY_PAGE_DOWNMove down about one screenfull of lines
KEY_TOGGLE_INSERTSwitch from inserting to overwriting or the reverse
KEY_NEW_LINECreate a new line, moving to it
KEY_DEL_LEFTDelete the character to the left of the cursor
KEY_DEL_RIGHTDelete the character at the cursor position
KEY_READ_FILEInsert the contents of a specified file before the current line
KEY_UPPER_CASEChange the character at the cursor position to its upper-case equivalent
KEY_LOWER_CASEChange the character at the cursor position to its lower-case equivalent
KEY_TOGGLE_CASEIf the character at the cursor is lower case, make it upper, and vice versa
KEY_TO_HEXReplace the character at the cursor with its two-character hexadecimal code
KEY_FROM_HEXReplace two hex characters starting at the cursor with the byte value
KEY_TO_BINARYReplace the character at the cursor with eight binary digits
KEY_HEX_TO_BINARYReplace one hex character at the cursor with four binary digits
KEY_BREAK_LINEMake the current line as short as the previous one, continuing on the next line
KEY_CHANGE_NAMEChange the name of the current file
KEY_REFORMAT_PARAGRAPHWrap the current line according to the right margin
KEY_SET_RIGHT_MARGINSet the value of the right margin; by default it is 76 characters
KEY_SUBSTITUTEInsert the string from the keymap table into the text
KEY_ANOTHER_FILEBegin editing another file
KEY_PREV_FILEGo to the previous file in the linked list
KEY_NEXT_FILEGo to the next file in the linked list
KEY_TOGGLE_BINARYOn output, interpret the current text as hexadecimal code
KEY_SHOW_MENUSActivate the menus
KEY_PRINT_SIZESet the size of printed type
KEY_PRINT_TOPSet the top margin for printing
KEY_PRINT_BOTTOMSet the bottom margin for printing
KEY_PRINT_LEFTSet the left margin for printing
KEY_PRINT_RIGHTSet the right margin for printing
KEY_PRINT_NUMBERIndicate whether printed lines should be numbered
KEY_PRINT_ORIENTATIONIndicate how the letters should be oriented on the printed page
KEY_PRINT_FOOTERIndicate whether the file name and date should be printed
KEY_PRINT_COMMANDSet the system command used to print the PostScript file
KEY_PS_PRINTCreate a PostScript version of the current file
KEY_PS_PRINT_BLOCKCreate a PostScript version of the current block
KEY_ADD_KEYSRead a text file describing keymap entries; merge them with the existing key definitions.

Default key actions sorted by key group

Here and in the tables that follow, the editor action names are given without the prefix KEY_ in order to simplify the tables.

Fn keys

	Fn or Shift-Fn		Ctrl-Fn		Alt-Fn
F1	SAVE_AND_EXIT		CHANGE_NAME	reserved
F2	QUIT			TO_HEX		reserved
F3	SAVE_FILE		FIND_MATCH	reserved
F4	GO_TO_LINE		FROM_HEX	reserved
F5	COPY_BLOCK		WRITE_FILE	reserved
F6	MOVE_BLOCK		DEL_BLOCK	reserved
F7	MARK_BLOCK_START	READ_FILE	reserved
F8	MARK_BLOCK_END		PS_PRINT	reserved
F9	DUP_LINE		BREAK_LINE	reserved
F10	DUP_CHAR		TOGGLE_BINARY	reserved

Numeric Keypad

		key			Ctrl-key
KP_7		MOVE_TO_BEG_OF_LINE	MOVE_TO_BEG_OF_FILE
KP_8		MOVE_UP			MOVE_TO_TOP_OF_SCREEN
KP_9		PAGE_UP			SCROLL_UP
KP_4		MOVE_LEFT   		WORD_LEFT
KP_5		IGNORE			IGNORE
KP_6		MOVE_RIGHT		WORD_RIGHT
KP_1		MOVE_TO_END_OF_LINE	MOVE_TO_END_OF_FILE
KP_2		MOVE_DOWN		MOVE_TO_BOTTOM_OF_SCREEN
KP_3		PAGE_DOWN		SCROLL_DOWN
KP_0		TOGGLE_INSERT		TOGGLE_AUTOINDENT
KP_Decimal	DEL_RIGHT		DEL_TO_EOL
KP_Enter	NEW_LINE		not assigned

"Gray" keys (so called because these keys are darker on IBM keyboards)

		key or Shift-key	Ctrl-key
Insert		TOGGLE_INSERT		TOGGLE_AUTOINDENT
Delete		DEL_RIGHT		DEL_TO_END_OF_LINE
Home		MOVE_TO_BEG_OF_LINE	MOVE_TO_BEG_OF_FILE
End		MOVE_TO_END_OF_LINE	MOVE_TO_END_OF_FILE
Page Up		PAGE_UP			SCROLL_UP
Page Down	PAGE_DOWN		SCROLL_DOWM
Left		MOVE_LEFT		WORD_LEFT
Right		MOVE_RIGHT		WORD_RIGHT
Up		MOVE_UP			MOVE_TO_TOP_OF_SCREEN
Down		MOVE_DOWN		MOVE_TO_BOTTOM_OF_SCREEN
Backspace	DEL_LEFT		DEL_TO_BEG_OF_LINE
Tab		(tab)			SET_TAB_WIDTH

Alt-letters

Alt-b		SET_RIGHT_MARGIN
Alt-e		ANOTHER_FILE
Alt-f		SEARCH_BACKWARDS
Alt-p		SET_PASTE_TEXT
Alt-q		QUIT
Alt-r		REPLACE_ALL
Alt-x		SAVE_AND_EXIT
Alt-1		UPPER_CASE
Alt-2		LOWER_CASE
Alt-3		TOGGLE_CASE
Alt->		NEXT_FILE
Alt-<		PREV_FILE

Control-letters

Ctrl-w	SCROLL_DOWN
Ctrl-e	MOVE_UP
Ctrl-r	REPLACE_ONCE
Ctrl-t	DEL_SPACE_TO_RIGHT
Ctrl-y	DEL_LINE
Ctrl-u	UNDEL LINE
Ctrl-i	(tab)
Ctrl-p	PASTE

Ctrl-s	MOVE_LEFT
Ctrl-d	MOVE_RIGHT
Ctrl-f	SEARCH_FORWARD
Ctrl-g	DEL_RIGHT
Ctrl-l	FIND_NEXT

Ctrl-z	SCROLL_DOWM
Ctrl-x	MOVE_DOWN
Ctrl-v	TOGGLE_TAB_VISIBILITY
Ctrl-b	REFORMAT_PARAGRAPH

Default key actions sorted by function:

File and session management

CHANGE_NAME		CTRL-F1
ANOTHER_FILE		Alt-E
PS_PRINT		CTRL-F8, Print
PREV_FILE		Alt-<
NEXT_FILE		Alt->
READ_FILE		CTRL-F7
SAVE_FILE		F3, SHFT-F3
SAVE_AND_EXIT		ALT-x, F1, SHFT-F1
QUIT			ALT-q, F2, SHFT-F2

Block operations

MARK_BLOCK_START	F7, SHFT-F7
MARK_BLOCK_END		F8, SHFT-F8
COPY_BLOCK		F5, SHFT-F5
MOVE_BLOCK		F6, SHFT-F6
DEL_BLOCK		CTRL-F6
WRITE_BLOCK		CTRL-F5

Cursor movement

MOVE_UP			 CTRL-SHFT-E, CTRL-e, KP_8, SHFT-Up, Up
MOVE_DOWN		 CTRL-SHFT-X, CTRL-x, Down, KP_2, SHFT-Down
MOVE_LEFT		 CTRL-SHFT-S, CTRL-s, KP_4, Left, SHFT-Left
MOVE_RIGHT		 CTRL-SHFT-D, CTRL-d, KP_6, Right, SHFT-Right
MOVE_TO_BEG_OF_LINE	 Home, KP_7, SHFT-Home
MOVE_TO_END_OF_LINE	 End, KP_1, SHFT-End
MOVE_TO_TOP_OF_SCREEN	 CTRL-KP_8, CTRL-Up
MOVE_TO_BOTTOM_OF_SCREEN CTRL-Down, CTRL-KP_2
MOVE_TO_BEG_OF_FILE	 CTRL-Home, CTRL-KP_7
MOVE_TO_END_OF_FILE	 CTRL-End, CTRL-KP_1
PAGE_UP			 KP_9, Prior, SHFT-Prior
PAGE_DOWN		 KP_3, Next, SHFT-Next
WORD_LEFT		 CTRL-KP_4, CTRL-Left
WORD_RIGHT		 CTRL-KP_6, CTRL-Right
SCROLL_UP		 CTRL-KP_9, CTRL-Prior, CTRL-SHFT-W, CTRL-w
SCROLL_DOWN		 CTRL-KP_3, CTRL-Next, CTRL-SHFT-Z, CTRL-z
GO_TO_LINE		 F4, SHFT-F4

Search and replace

SEARCH_FORWARD		CTRL-f
SEARCH_BACKWARD		ALT-f
FIND_NEXT		CTRL-SHFT-L, CTRL-l
REPLACE_ONCE		CTRL-r
REPLACE_ALL		ALT-r
SET_PASTE_TEXT		ALT-p
PASTE			CTRL-p
FIND_MATCH		CTRL-F3

Insert and delete

NEW_LINE		KP_Enter, Return, SHFT-KP_Enter, SHFT-Return
DUP_CHAR		F10, SHFT-F10
DUP_LINE		F9, SHFT-F9
DEL_LEFT		BackSpace, SHFT-BackSpace
DEL_RIGHT		CTRL-SHFT-G, CTRL-g, Delete, KP_Decimal,
			SHFT-Delete
DEL_LINE		CTRL-SHFT-Y, CTRL-y
UNDEL_LINE		CTRL-SHFT-U, CTRL-u
DEL_SPACE_TO_RIGHT	CTRL-SHFT-T, CTRL-t
DEL_TO_BEG_OF_LINE	CTRL-BackSpace
DEL_TO_END_OF_LINE	CTRL-Delete, CTRL-KP_Decimal
LOWER_CASE		ALT-2
UPPER_CASE		ALT-1
TOGGLE_CASE		ALT-3
BREAK_LINE		CTRL-F9
REFORMAT_PARAGRAPH	CTRL-b, CTRL-SHFT-B

Miscellaneous

SET_TAB_WIDTH		CTRL-Tab
TOGGLE_TAB_VISIBILITY	CTRL-SHFT-V, CTRL-v
TOGGLE_INSERT		Insert, KP_0, SHFT-Insert
TOGGLE_AUTOINDENT	CTRL-Insert, CTRL-KP_0
SET_RIGHT_MARGIN	ALT-b
IGNORE			CTRL-KP_5, KP_5

Menu actions

The menu items are simple structures consisting of a descriptive string and an editor action code. When an item is selected, the action code is executed through a call to process_key. These tables show the menu items and their corresponding actions.

File

Another file		KEY_ANOTHER_FILE
Save and exit		KEY_SAVE_AND_EXIT
Save file		KEY_SAVE_FILE
Change name		KEY_CHANGE_NAME
Prev file		KEY_PREV_FILE
Next file		KEY_NEXT_FILE
PS Print		KEY_PS_PRINT
Add keys		KEY_ADD_KEYS
Quit			KEY_QUIT

View

Toggle insert		KEY_TOGGLE_INSERT
Toggle autoindent	KEY_TOGGLE_AUTOINDENT
Toggle tab visibility	KEY_TOGGLE_TAB_VISIBILITY
Set tab width		KEY_SET_TAB_WIDTH
Set right margin	KEY_SET_RIGHT_MARGIN
Scroll up		KEY_SCROLL_UP
Scroll down		KEY_SCROLL_DOWN

Move

Word left		 KEY_WORD_LEFT
Word right		 KEY_WORD_RIGHT
Move to top of screen	 KEY_MOVE_TO_TOP_OF_SCREEN
Move to bottom of screen KEY_MOVE_TO_BOTTOM_OF_SCREEN
Move to beg of line	 KEY_MOVE_TO_BEG_OF_LINE
Move to end of line	 KEY_MOVE_TO_END_OF_LINE
Move to beg of file	 KEY_MOVE_TO_BEG_OF_FILE
Move to end of file	 KEY_MOVE_TO_END_OF_FILE
Page up			 KEY_PAGE_UP
Page down		 KEY_PAGE_DOWN
Find match		 KEY_FIND_MATCH
Go to line		 KEY_GO_TO_LINE

Find

Search forward		KEY_SEARCH_FORWARD
Search backward		KEY_SEARCH_BACKWARD
Find next		KEY_FIND_NEXT
Find nonprintable	KEY_FIND_NEXT_NONPRINTABLE
Set paste text		KEY_SET_PASTE_TEXT
Paste			KEY_PASTE
Replace once		KEY_REPLACE_ONCE
Replace all		KEY_REPLACE_ALL

Block

Mark block start	KEY_MARK_BLOCK_START
Mark block end		KEY_MARK_BLOCK_END
Copy block		KEY_COPY_BLOCK
Move block		KEY_MOVE_BLOCK
Write block		KEY_WRITE_BLOCK
Del block		KEY_DEL_BLOCK
Print block		KEY_PS_PRINT_BLOCK
Hide block		KEY_HIDE_BLOCK

Change

Del space to right	KEY_DEL_SPACE_TO_RIGHT
Del line		KEY_DEL_LINE
UnDelete line		KEY_UNDEL_LINE
Del to beg of line	KEY_DEL_TO_BEG_OF_LINE
Del to end of line	KEY_DEL_TO_END_OF_LINE
Dup char		KEY_DUP_CHAR
Dup line		KEY_DUP_LINE
New line		KEY_NEW_LINE
Break line		KEY_BREAK_LINE
Reformat paragraph	KEY_REFORMAT_PARAGRAPH
Read file		KEY_READ_FILE
Toggle Binary File	KEY_TOGGLE_BINARY

Convert

Upper case		KEY_UPPER_CASE
Lower case		KEY_LOWER_CASE
Toggle case		KEY_TOGGLE_CASE
To hex			KEY_TO_HEX
From hex		KEY_FROM_HEX
To binary		KEY_TO_BINARY
Hex to binary		KEY_HEX_TO_BINARY

Print

Type size		KEY_PRINT_SIZE
Top margin		KEY_PRINT_TOP
Bottom margin		KEY_PRINT_BOTTOM
Left margin		KEY_PRINT_LEFT
Line numbers		KEY_PRINT_NUMBER
Page orientation	KEY_PRINT_ORIENTATION
Page footers		KEY_PRINT_FOOTER
Set print command	KEY_PRINT_COMMAND
PS Print		KEY_PS_PRINT

Programmer's Guide

Design:

Xed is intended to be simple, fast, and easily customized. Note that "full-featured" is not one of the stated goals. The design goals have been approached using three specific strategies:
  1. The operation of the editor is minimally modal, which means that most of the time you can execute most of the commands. This is in sharp contrast to vi, in which the things you can do at any time are dictated by the mode you are in, and you have to press a specific key to exit your current mode before you can do anything else.
  2. The relationship between keystrokes and editing operations is determined by a table which presently resides in the source code. To make the keys do different things, just change the table and recompile. In principle, this table could be read from disk at run time, but most users will want to set it up once and keep it that way.

How to change the default key assignments:

To configure the keyboard differently than I have, just edit the keymap table in keymap.c to reflect your desires. The anatomy of an entry is shown below. Each entry is a structure consisting of two integers, whose values are specified using the names of predefined constants, and a character string. The first value indicates the key struck and the associated modifier keys, Control, Shift, and Alt. The second value is the editor action you want taken when this key is pressed. To determine exactly what each editor action does, look in process_key() in xed.c. The third value is a string that is inserted in the text if the key action is KEY_SUBSTITUTE.

The keystroke is described by the logical OR of the modifier keys (CTRL, SHFT, ALT) with the KeySym, the name X11 uses for the key. A section of the keymap table is reproduced below.

{CTRL |    0 |   0 | XK_BackSpace,	KEY_DEL_TO_BEG_OF_LINE,	NULL},
{CTRL |    0 |   0 | XK_KP_Decimal,	KEY_DEL_TO_END_OF_LINE,	NULL},
{CTRL |    0 |   0 | XK_Delete,		KEY_DEL_TO_END_OF_LINE,	NULL},
{CTRL |    0 |   0 | XK_Escape,		KEY_SHOW_VARIABLES,	NULL},
{   0 |    0 | ALT | XK_1,		KEY_UPPER_CASE,		NULL},
{   0 |    0 | ALT | XK_2,		KEY_LOWER_CASE,		NULL},
{   0 |    0 | ALT | XK_3,		KEY_TOGGLE_CASE,	NULL},
{   0 |    0 | ALT | XK_b,		KEY_SET_RIGHT_MARGIN,	NULL},
{   0 |    0 | ALT | XK_n,		KEY_ANOTHER_FILE,	NULL},
The symbols CTRL, SHFT, and ALT indicate the activity of these modifier keys. A zero in one of those columns means that the corresponding modifier is not activated. Caps Lock is treated like Shift. The symbols beginning with XK_ are KeySyms, which are defined in the header file /usr/include/X11/keysymdef.h

Note that in X11, an upper case KeySym, like XK_D, must always be used with SHFT. Note also that the window manager may usurp some keys for its own use, not permitting the application to see these keys. On the DG AViiON, for example, Motif is usually configured to use Alt-F1 through Alt-F10, Alt-Tab, Alt-space, and Alt-Esc, so it will do no good to define key bindings for them. The window manager's key usage is controlled by its rc file (e.g. .mwmrc).

How to change the menus

You can add an item to an existing menu by finding that menu's xed_menu structure, and adding an element to the choice array; each element of this array is a structure containing the menu item text and an xed_action. The last element in each choice array must have a NULL pointer as the text. The choice arrays are limited in size to MAX_MENU_ITEMS each; change this constant to enlarge or shrink the array.

Needed enhancements:

A number of features do not work as well as they should. There should be a help facility of some sort. There should be a macro facility of some sort. Blocks should not be restricted to whole lines.

Download

http://geology.usgs.gov/peter/xed/

Technical contact:

  Peter N. Schweitzer
  MS 954 National Center
  U.S. Geological Survey
  Reston, VA 22092

  Tel:   (703) 648-6533
  FAX:   (703) 648-6252
  email: pschweitzer@usgs.gov