libedit

command line recall and editing

DESCRIPTION

The BSD libedit library is linked with C-PLOT to make available the following filename completion, history substitution and command line editing features.

HISTORY FILE

C-PLOT command history is saved in the file .cplot_history in the user's home directory. History for the type 5 fitting functions is saved in the file .cplotfit_history with all fitting functions sharing the same file. Up to 1000 of the most recent commands are saved in each file.

FILENAME COMPLETION

The <tab> key can be used to complete the second or subsequent words being typed, using as possible completions all the file and directory names in the current directory.

If only one completion is possible, typing the <tab> key will generate the completion. If a small number of completions are available, typing the <tab> key twice will list them, followed by a redisplay of the current input line. If a large number of completions are possible, typing the <tab> will generate a prompt asking if all should be displayed.

The sequences ~/ and ~any_user/ will be replaced by the full path names for the current user's and any user's home directory.

HISTORY SUBSTITUTION - EVENT SPECIFIERS

All or part of a previous command can be recalled for the current command using a string starting with the ! event specifier character. The following event specifiers may appear anywhere in the input line.

!!
The previous command.
!N
Command number N.
!-N
The Nth previous command.
!string
The most recent command starting with string.
!?string[?]
The most recent command containing string. The trailing ? is optional at the end of a line.

HISTORY SUBSTITUTION - WORD DESIGNATORS

Individual words from previous commands can be recalled by adding a word designator to the event specifier. A colon (:) separates the two components and can be omitted if the word designator begins with the characters ^, $, * or %. Words are numbered from the beginning of the line, starting with a 0 (zero).

0
The 0th word.
N
The Nth word.
^
Word 1. !^ refers to word 1 of the previous command.
$
The last word. !$ refers to the last word of the previous command.
%
The word most recently matched by a ?string?.
N-M
A range of words; -N Abbreviates 0-N.
*
All of the words, except the 0th. This is the same as 1-$. If there is just one word (the 0th) in the event, an empty string is substituted.
N*
Same as N-$.
N-
Same as N-$, but doesn't include the last word.

HISTORY SUBSTITUTION - MODIFIERS

One or more modifiers may follow the optional word designator, each preceded by a :, as follows:

#
The entire command line typed so far.
h
Remove a trailing path name component of the form /pathname.
r
Remove a trailing suffix of the form .suffix.
e
Remove all but the suffix.
t
Remove all leading path name components.
s/left/right[/]
Substitute the first occurrence of the string left with the string right. The pattern delimiter can be any character. An & character in right is replaced by left, unless the & is preceeded by a single backslash. The trailing delimiter is optional if right is at the end of the line.
g
When used with s, apply the substitution to each occurrence of the string left.
p
Print the new command but do not execute it.

The usage ^left^right^ is shorthand for !!:s/left/right/.

HISTORY FILE

The C-PLOT command history will be saved to a file called .cplot_history in the user's home directory. Command history associated with any of the type-5 fitting functions will be saved in a single file called .cplotfit_history.

COMMAND LINE EDITING

The following special keys can be used to recall previous command lines and to modify the current command line. In addition to the control keys described below, the up and down arrow keys move through the history, while the left and right arrow keys move the cursor within the currently displayed line.

The command names listed are the names you would use in an optional key-bindings file. See the documentation for for libedit for information on setting up the key bindings file. C-PLOT will arrange for a key-bindings file named .cplot_keys in the C-PLOT user's home directory to be loaded, if it exists.

^A

Move to the beginning of the current line.

binding: ed-move-to-beg

^E

Move to the end of the current line.

binding: ed-move-to-end

ESC f

Move forward to the end of the next word.

binding: em-next-word

ESC b

Move to the start of the current or previous word.

binding: ed-prev-word

^L

Clear the screen and reprint the current line at the top.

binding: ed-clear-screen

^K

Kill from the cursor to the end of the line.

binding: ed-kill-line

ESC d

Kill from the cursor to the end of the current word. If between words, kill to the end of the next word.

binding: em-delete-next-word

ESC DEL

Kill from the cursor the start of the previous word. If between words, kill to the start of the previous word.

binding: ed-delete-prev-word

^W

Kill from the cursor to the previous white space.

binding: em_kill_region

^Y

Insert the most recently killed text at the cursor.

binding: em-yank

^F

Move forward a character.

binding: ed-next-char

^B

Move back a character.

binding: ed-prev-char

<return>

Accept the line regardless of where the cursor is. If non-empty, add the line to the history list.

binding: ed-newline

^P

Move up through the history list.

binding: ed-prev-history

^N

Move down through the history list.

binding: ed-next-history

^R

Search backward, incrementally, starting at the current line and moving up through the history as necessary.

binding: em-inc-search-prev

^S

Search forward starting at the current line and moving down through the the history as necessary.

binding: em-inc-search-next

^D

Delete the character under the cursor.

binding: em-delete-or-list

^H,

DEL Delete the character behind the cursor. A numeric argument means kill the characters instead of deleting them.

binding: ed-delete-prev-char

^Q,

^V Add the literal next character to the line.

binding: ed-quoted-insert

a,

b, etc. Characters to be inserted as themselves.

binding: ed-insert

^T

Transpose the previous and current characters and move forward one character.

binding: ed-transpose-chars

ESC ^_

Insert a copy of the previous word

em_copy_prev-word

ESC u

Capitalize the current word.

binding: em-upper-case

ESC l

Make the current word lower case.

binding: em-lower-case

ESC c

Capitalize the current word.

binding: em-capitol-case

^U

Kill the current line.

binding: em-kill-line

ESC 0,

ESC 1, ... Enter number arguments for commands that can operate on more than one object.

binding: ed-argument-digit

^G,

ESC ^G, ^X ^G Stop.

binding: no binding, but ^G aborts incremental seaches

ESC

Use this character as a meta prefix for keyboards that lack a meta key.

binding: em-meta-next

^_,

^X ^U Undo last change.

binding: vi-undo, only one level of undo

ESC r,

ESC ^R Undo all changes made to this line.

binding: vi-undo-line

unbound

Redraw the current line.

binding: ed-redisplay

NOTES

With the optional history libraries, the ! character must be preceded by a \ when it is typed from the keyboard and is not intended to be part of a history substitution.

DISTRIBUTION

A prebuilt version of the NetBSD libedit library is included with the C-PLOT distribution in the overhead subdirectory. The official source respository for the NetBSD version is at http://cvsweb.netbsd.org/bsdweb.cgi/src/lib/libedit. Portable versions configurable for other platforms are available from www.thrysoee.dk/editline , although that site doesn't always have the most recent version. The source for the prebuilt version included with the C-PLOT distribution is available at certif.com/downloads/extras .