In this chapter we shall methodically overview each part of ne
. It
is required reading for becoming an expert user because some commands
and features are not available through menus.
The main arguments you can give to ne
are the names of files you
want to edit. They will be loaded into separate documents.
The --noconfig
option skips the reading of the key
bindings and menu configuration files (see section Configuration). This is
essential if you are experimenting with a new configuration and you make
mistakes in it.
The --macro filename
option specifies the name of a
macro that will be started just after all documents have been loaded. A
typical macro would move the cursor to a certain line.
The --keys filename
option and the --menus
filename
option specify a name different from the default one
(`.keys' and `.menus', respectively) for the key bindings and
the menu configuration files. Note that ne
searches for these
files first in the current directory, and then in your `~/.ne'
directory.
Finally, the --ansi
and the --noansi
options manage
ne
's built-in ANSI sequences. Usually ne
tries to retrieve
from your system some information that is necessary to handle your
terminal. If for some reason this is impossible, you can ask ne
to use a built-in set of sequences that will work on many terminals
using the --ansi
option (to be true, ne
can be even
compiled so that it uses directly the built-in set, but you need not
know this). If you want to be sure (usually for debugging purposes) that
ne
is not using the built-in set, you can specify
--noansi
.
The last line of the screen, the status bar, is reserved by
ne
for displaying some information about its internal state.
Note that on most terminals it is physically impossible to write a
character on the last column of the last line, so we are not
stealing precious editing space.
The status bar looks more or less like this:
L: 31 C: 25 iabcwfpvurBMRP* 20 /foo/bar
The numbers after `L:' and `C:' are the line and column of the cursor position. The first line and the first column are both number 1.
Following that are a sequence of letters or dashes. These indicate the status of a series of flags which we shall look at later.
The two hexidecimal digits following the flags are the code for the character at the cursor, and are displayed optionally (see section HexCode). If your cursor is at or beyond the right end of the current line, the code shown is `00'.
The file name appearing after the character code is the file name of
the current document. The left end of very long file names may be
truncated to keep the right end visible. Of course,
ne
is keeping track internally of the complete file name. It
is used by the Save
command and as the default input for the
SaveAs
command. See section Save, and section SaveAs.
The displayed line and column numbers and the character code change when
the cursor moves. This fact can really slow down cursor movement if
you are using ne
through a slow connection. If you find this a
problem, it is a good idea to turn off the status bar using either the
`Status Bar' menu item of the `Prefs' menu or the
StatusBar
command. See section StatusBar. Note that if you really need
the speed, you could also to turn on the fast GUI mode using either the
`Fast GUI' menu item of the `Prefs' menu or the
FastGUI
command (see section FastGUI). In fast GUI mode the
status bar is not draw in reverse, so some additional optimization can
be done when refreshing it.
The letters after the line and column number represent the status of the flags
associated with the current document. Flags that are off display a
`-' instead of a letter. Each flag also has an
associated command. The Flags
command describes them all when
you don't have this manual handy. Here's the list in detail:
Modified
command was issued to set this flag. See section Modified.
Note that sometimes ne
needs to communicate some message to you. The
message is usually written over the status bar, where it stays
until you do something. Any action such as moving the cursor or inserting a
character will restore the normal status bar.
The bottom line of the screen is usually occupied by the status bar
(see section The Status Bar). However, whenever ne
prompts you for a
command or file name or asks you to confirm some action, the bottom line
becomes the input line. You can see this because a prompt is
displayed at the start of the line, suggesting what kind of input is
required. (Prompts always ends with a colon, so it is easy to
distinguish them from error messages, which overwrite the status
line from time to time.)
ne
uses the input line in two essentially different ways:
immediate input and long input. You can easily distinguish
between these two modes because in immediate input mode the cursor is
not on the input line, while for long input mode it is.
Immediate input is used whenever ne
needs you to specify a simple
choice that can be expressed by one character (for example, `y' or
`n'). When you type the character, ne
will immediately
accept and use your input. Most immediate inputs display a character
just after the prompt. This character is the default response, which is
used if you just press the Return key. Note that immediate input
is not case sensitive. Moreover, if a yes/no choice is requested,
anything other than `y' will be considered a negative
response.
Long input is used when a whole string is required. You can enter and
edit your response to long inputs like a line of text in a document. All
the key bindings related to line editing work on the command line
exactly as they do in a document. This is true even of custom key
bindings. Just edit as you are used to. Moreover, the contents of the
input line can be replaced by the first line of the current clip using
the keystroke that is bound to the Paste
command, usually
Control-V. If your long input is longer than the screen
width, the input line scrolls to accomodate your text so you can input
very long lines even on small monitors. (There is a limit of 1024
characters.)
The default response to a long input is the response you gave to the previous long input. Your first action when presented with a long input will either erase the default response or allow you to edit it. If the first thing you type is a printing character, the default response will be erased. Anything else (cursor movement for example) will allow you to edit it further.
Long input also lets you access your previous long input responses with
the up and down cursor commands. Once you find a previous input you like,
you can edit it further. Long input history is not document
specific, so you can recall any of your inputs regardless of which
document was active when you entered it. Furthermore, ne
saves
the most recent long inputs in `~/.ne/.history' when you end
your ne
session and loads them again when you begin another
ne
session.
When asked to input a number, you can choose between decimal, octal and hexadecimal notation in the standard way: a number starting with `0' is considered in octal, a number starting with `0x' is considered in hexadecimal, and in all other cases decimal base is assumed.
Whenever a file name is requested, you can type a partial file name and
complete it with the Tab key. ne
will scan the
current directory (or the directory that you partially specified) and
search for the files matching your partial suggestion. The longest
prefix common to all such files will be copied on the input line
(ne
will beep if no completion exists). It's easier done than
said--just try. If you press Tab again, you will be brought into
the file requester: only the files and directories matching your partial
specification will appear, and as usual you will be able to navigate and
select a file or escape. See section The Requester. Note that ne
considers the last word on the input line the partial file name
to complete, no matter where the cursor is currently (you can use quotes
if the name contains spaces).
Complete long input with the Return key. You can cancel a long
input using f1, Escape, or any key that is bound to the
Escape
command. The effect will vary depending on what your were
requested to input, but the execution of the command requiring the input
will stop.
The command line is a typical (topical) way of controlling an editor on
character driven systems. It has some advantages over menus in terms of
access speed, but it is not desirable from a user interface point of
view. ne
has a command line that should be used whenever strange
features have to be accessed, or whenever you want to use a command that
you are familiar with and that is not bound to any key.
You have two ways to access the command line: by activating the menu and
typing a colon (`:') or by typing Control-K (or any key
that is bound to the Exec
command; see section Exec). The first
method will work regardless of any key binding configuration if you
activate the menus with the Escape key since that key cannot be
reconfigured. Of course, there is also a menu entry that does the same
job.
Once you activate the command line, the status bar will turn into an input line (see section The Input Line) with a `Command:' prompt waiting for you to do a long input. In other words, you can now type any command (possibly with arguments), and when you press Return, the command will be executed.
If the command you specify does not appear in ne
's internal tables,
it is considered to be the name of a macro. See section Basic Macros, for details.
In various situations, ne
needs to ask you to choose one string
from several (where "several" can mean a lot, even hundreds).
For this kind of event, the requester is issued. The requester
displays the strings in as many columns as possible and lets you move
with the cursor from one string to another. The strings can fill many
screens, which are handled as consecutive pages. All the navigation keys
work exactly as in normal editing. This is true even of custom key
bindings. Thus, for instance, you can page up and down through the
list with Control-P and Control-N (in the standard keyboard
configuration).
As with the input line (see section The Input Line), you can confirm your
input with Return or escape the requester with f1 or the
Escape key (or whatever has been bound to the Escape
command). Moreover, if you are selecting a file name there is a third
possibility: by escaping with the Tab key, the file or directory
name that the cursor is currently on will be copied on the input
line. This allows to choose an existing name and modify it.
A special feature is bound to alphabetic characters: they move you to the next entry starting with the letter you typed. The search is case insensitive, and it continues on to the first string after having passed the last one.
An example of a requester is the list of commands appearing when you use
the Help
command. Another example is the file requester that
ne
issues whenever a file operation is going to take place. In
this case, pressing Return while on a directory name will enter
the directory. Note also that, should the requester take too long to
appear, you can interrupt the directory scanning with
Control-\. However, the listing will likely be incomplete.
Note that there are two items that always appear in the file requester: `./' and `../'. The first one represents the current directory and can be used to force a reread of the directory. The second one represents the parent directory and can be used to move up by one directory level.
ne
's menus are extremely straightforward. The suggested way of
learning their use is by trial and error, with a peek here and there
at this manual when some doubts arise.
You activate menus with the f1 key, or in case your keyboard does
not have such a key, Escape, or any key that is bound to the
Escape
command. Move around the menus pressing with the cursor
keys and the page up/down keys (which move to the first or last menu
item in a menu). You can also move around menus and menu items by
pressing the alphabetic keys; a lower case letter will move to the first
item in the current menu whose name starts with the given letter; an
upper case letter will move to the first menu whose name starts with the
given letter.
Each menu item of ne
's standard menu corresponds to a
single command. In explaining what each menu item allows you to
do, we shall simply refer you to the section that explains the command
relative to the menu item.
If you plan to change ne
's menu (see section Changing Menus), you should
take a look at the file `default.menus' that comes with ne
's
distribution. It contains a complete menu configuration that clones the standard
one.
The File menu contains standard items that allow loading and saving
files. Quitting ne
(which doesn't save changes) or exiting
ne
(which does save changes) is also possible.
The Documents menu contains commands that create new documents, destroy them, and browse through them.
The Edit menu contains commands related to cutting and pasting text.
The Search menu contains commands related to searching for specific contents or locations within a document.
The Macros menu contains commands related to creating and using macros.
This menu contains a few special items that don't fit in obvious ways into other menus.
The Navigation menu contains commands related moving around in a document.
The Prefs menu contains commands related to setting, storing, and using your prefered document flags.
Regular expressions are a powerful way of specifying complex search and replace operations.
The following section is taken (with minor modifications) from the GNU regular expression library documentation and is Copyright (C) Free Software Foundation.
A regular expression describes a set of strings. The simplest case is one that describes a particular string; for example, the string `foo' when regarded as a regular expression matches `foo' and nothing else. Nontrivial regular expressions use certain special constructs so that they can match more than one string. For example, the regular expression `foo|bar' matches either the string `foo' or the string `bar'; the regular expression `c[ad]*r' matches any of the strings `cr', `car', `cdr', `caar', `cadddar' and all other such strings with any number of `a''s and `d''s.
Regular expressions have a syntax in which a few characters are special constructs and the rest are ordinary. An ordinary character is a simple regular expression which matches that character and nothing else. The special characters are `$', `^', `.', `*', `+', `?', `[', `]' , `(', `)' and `\'. Any other character appearing in a regular expression is ordinary, unless a `\' precedes it.
For example, `f' is not a special character, so it is ordinary, and therefore `f' is a regular expression that matches the string `f' and no other string. (It does not match the string `ff'.) Likewise, `o' is a regular expression that matches only `o'.
Any two regular expressions a and b can be concatenated. The result is a regular expression that matches a string if a matches some amount of the beginning of that string and b matches the rest of the string.
As a simple example, we can concatenate the regular expressions `f' and `o' to get the regular expression `fo', which matches only the string `fo'. Still trivial.
Note: special characters are treated as ordinary ones if they are in contexts where their special meanings make no sense. For example, `*foo' treats `*' as ordinary since there is no preceding expression on which the `*' can act. It is poor practice to depend on this behavior; better to quote the special character anyway, regardless of where is appears.
The following are the characters and character sequences that have special meaning within regular expressions. Any character not mentioned here is not special; it stands for exactly itself for the purposes of searching and matching.
Also the replacement string has some special feature when doing a regular expression search and replace. Exactly as during the search, `\' followed by digit stands for "the text matched the digit'th time by the `( ... )' construct in the search expression". Moreover, `\0' represent the whole string matched by the regular expression. Thus, for instance, the replace string `\0\0' has the effect of doubling any string matched.
Another example: if you search for `(a+)(b+)', replacing with `\2x\1', you will match any string composed by a series of `a''s followed by a series of `b''s, and you will replace it with the string obtained by moving the `a' in front of the `b''s, adding moreover `x' inbetween. For instance, `aaaab' will be matched and replaced by `bxaaaa'.
Note that the backslash character can escape itself. Thus, to put a backslash in the replacement string, you have to use `\\'.
Automatic preferences let you set up a custom configuration that is automatically used whenever you open a file with a given extension. For instance, you may prefer a TAB size of three when editing C sources, but eight could be more palatable when writing electronic mail.
The use of autoprefs is definitely straightforward. You simply use the
`Save AutoPrefs' menu item (or the SaveAutoPrefs
command;
see section SaveAutoPrefs) when the current document has the given extension and
the current configuration suits your tastes. The internal state of a series of
options will be recorded as a macro containing commands that reproduce the
current configuration. The macro is then saved in the `~/.ne'
directory (which is created if necessary) with the name given by the
extension, postfixed with `#ap'. Thus, the C sources automatic
preferences file will be named `c#ap', the one for TeX files `tex#ap',
and so on.
Macros are generated with short or long command names depending on the status of the verbose macros flag. See section VerboseMacros.
Automatic preferences files are loaded and executed whenever a file with a known extension is opened. Note that you can manually edit such files, and even insert commands, but any command that does something other than setting a flag will be rejected, and an error message will be issued.
When ne
is interrupted by an abnormal event (for instance, the
crash of your terminal), it will try to save all unsaved
documents in its current directory. Named documents will have their
names prefixed with a `#'. Unnamed documents will be given names
made up of hexadecimal numbers obtained by some addresses in memory
that will make them unique.
Go to the first, previous, next, last section, table of contents.