Medit - a Text Editor for Unix.
===============================
These are the files for the latest version 5.89
Medit is a text editor available for Unix-like environments* as a user friendly
alternative to "vi".
I hope you find Medit useful, and remind you that it comes with no guarantee
whatsoever.
It has been compiled & run on Sun Solaris, Linux, Silicon Graphics Unix,
Cygwin, Win32 console mode under Microsoft OSs, and even (with some work) on
MSDOS (although I doubt that it would still compile now).
I have included my shell wrapper script and keymapping files for use
with Putty and Cygwin.
I no longer supply precompiled versions, except for Solaris.
To compile/build Cygwin/Unix/Linux, I'm afraid you are on your own - you are going to have to compile
it yourself. I'm no longer going to let the endless incompatibilities of
different Unix flavours waste any more of my life.
I have included the script I use to compile it myself as an example.
There is no configure script yet - this is on my todo list. The compile.sh
script has been tested on Cygwin and Linux. Medit uses the Curses/Ncurses
and PCRE libraries.
1.0 Changes since version 5.69
==============================
5.70 - 5.73 Abandoned. Unsuccessful attempt to add a new feature.
5.74 1. bug fix: line count not reset after first file with
multiple files.
5.75 1. bug fix: action HUP signal by taking panic action.
5.76 1. bug fix: hangs on MX with no macro defined.
2. added extra comments in source.
5.77 1. change the attributes of replace string within marked block
to make more visible.
5.78 1. move-to-word & back-to-word no longer shift text upscreen.
5.79 1. line-number update fixed when inserting text into empty file.
this will also hopefully fix outstanding known bug which causes
line numbers to intermittently go wrong.
5.80 1. fix compiler errors under cygwin.
5.81 1. fix inconsistent back_to_word().
5.82 1. internal function renamed, no user visible change.
10.9.2010 5.83 1. bug fix: block paste at the start of the file or in an
empty file sometimes goes scarily wrong. rewrote the
pasteblock() function. maybe the same needs to happen
for the other xxxblock() functions, as the code really
is a mess.
5.11.2010 5.84 1. bug fix: single mark block;quit followed by single
mark block;quit caused crash.
2.0 Using Medit.
================
To see a list of commands available press the HELP key while in the editor.
If you are running Medit for the first time, and it states that it is using the
default key mapping, then press CTRL-X to get to the command line, then enter
"help" for help, or "quit" to exit.
Medit is designed to work with any keyboard & any terminal. Because every
terminal is different, and cannot be predicted, only a rudimentary keyboard
mapping is provided by default. A custom keyboard mapping will considerably
enhance the user-friendliness of Medit. See the section "Medit Key Mapping"
below on creating a keyboard mapping for your terminal.
Command line options available are:
-t Highlight tabs inverse on screen (text is not affected). Intended for
when editing files where tabs have special meaning (e.g. make files).
-k <keymap file> where <keymap file> is a file created earlier using the
MAP command in medit. For more details see under the heading
"Medit Key Mapping" below.
-r read-only mode - will not allow any writing of files.
-s <number> set tab stops to the <number> position.
-h displays command line options.
Known Bug.
----------
1. NULLs (ascii code 0) are stripped from the text, and a warning message
is given when this occurs. (Note that vi also does this). Therefore, Medit
usually CAN NOT be used to edit executable or binary files. Files containing
control characters can be edited, providing NULLs are not present.
Block Marking.
--------------
Blocks of text can be marked, on line by line basis only.
To mark a block, press the MARK BLOCK key at the start and end of the text
you wish to mark.
When a block is marked, the Copy Block, Move Block, and Cut Block
commands are available, and the block commands also copy the text to a buffer.
When the buffer has text in it, the Paste Block command will paste the text
to the current position in the file.
When a block is marked, Write, Replace and Macexec commands (which would
normally affect the whole file) then apply only to the block.
Macros.
-------
To define a macro: press the DEFINE MACRO key; then press any sequence of keys
except REPLAY MACRO; finally press DEFINE MACRO again to end the macro
definition.
The macro will then be defined as the sequence of keys you have pressed, and
can be replayed by pressing the REPLAY MACRO key.
If any command in the macro cannot be executed then the invocation of the
macro is aborted.
If you have a macro defined, and press DEFINE MACRO by mistake, then do not
despair! Press DEFINE MACRO again IMMEDIATELY, and the previously defined
macro will not be overwritten.
From the command line, the MACEXEC (or MX) command, will execute the macro
repeatedly, until finished (or interrupted by a key press). If a block is
marked, the macro is executed against the marked lines, otherwise against the
whole file. When a macro is operating against a marked block, any block
operation done by the macro will terminate macro execution - this is to limit
the amount confusion that can be generated in the user, in medit, and in the
programmer (me).
The MACEXEC and REPLAY MACRO commands cannot be executed from a macro - they
will be ignored.
Note that commands executed from a macro are not entered into the command
history. This was to minimise the risk of insanity in both the user and
the programmer!
Regular Expressions.
--------------------
Regular expressions can be searched for using the EXPR or X command. The Find
Forwards function key then repeats the search.
The syntax for expressions is similar to the "ed" editor, see the "ed" man
page for details. However, note that the regular expression library used is
PCRE, which has some differences from ed.
Regular expressions can not be searched backwards - sorry, but the library
subroutine calls do not support this. I intend to work around this one day,
but it will not be a trivial task, so don't hold your breath.
Regular expressions can also be used in a replace with the REPEXP or RX command,
where the replacement must be a string (not an expression).
Un-Printable Characters.
------------------------
Un-printable characters (or control characters) are shown on screen highlighted,
except for NULLs (ascii code 0) which are stripped from the text (note that vi
also does this). Because of this, Medit usually CAN NOT be used to edit
executable files. Binary files can be edited, providing NULLs are not present
in the text.
Un-printable characters are shown as follows.
ascii codes 1-26: highlighted "A" to "Z".
ascii codes 27-31: highlighted [ \ ] ^ _
ascii codes 127 and greater: highlighted "?".
Therefore ascii codes of 127 and greater can not be distinguished from
each other on screen - however string search and replace functions will
correctly detect such characters.
Control characters can be entered into the text or command line with the
CONTROL CHAR key. Press the CONTROL CHAR key, then enter any number of control
characters, then press RETURN - the control characters will then be entered into
the text or command line at the cursor position.
Control characters can be entered either as ASCII codes, or directly with the
CTRL key and an alphabetic key. When entering characters as ASCII codes, at
least one space should seperate each character value. Note that on Unix systems
the Ctrl-H, Ctrl-O, Ctrl-Q, Ctrl-S and characters above ASCII 127 can only be
entered using ASCII codes.
If there is a syntax error in the control characters, an error message is only
displayed when entering into text - when entering into the command line no
message is displayed, and the entire control character string is ignored.
Medit Key Mapping.
------------------
If you wish, you can define your own key mapping for Medit.
Use the MAP command from the command line with an empty file, then save the
resulting file as your keymap file.
The function names you are prompted to define key mappings for are mostly
self-explanatory, except for INVALID COMMAND. This should be mapped to all
keys on the your keyboard that send an escape sequence to the host, but for
which no medit function has been assigned. This ensures that the meaningless
escape sequences generated by these keys will not be inserted into the text.
To use your keymapping, invoke medit like this:
med -k <keymap file> <file to edit>
Or alternatively, set the environment variable MEDITKEYPATH to the directory
that contains your keymap file, in which case you do not have to explicitly
specify the -k <keymap file> parameter. The filenames in the directory
specified in the MEDITKEYPATH variable must be medit.key.<TERM> where <TERM>
is the terminal type as defined in the TERM variable. For example, for a
vt220 terminal, the keymap file should be called "medit.key.vt220".
If no keynapping is defined for your terminal, you get a default keymapping
which makes use of control keys, in a similar fashion to Emacs, or Wordstar.
Here is the full list of Medit functions that can be mapped to a key:
Name Decsription
---- -----------
Backwards Del. Char.
Tab
New Line.
Help.
Command Line. Go into command line mode.
Clear Line.
Delete Line.
Find Forwards.
Find Backwards.
Mark Block.
Copy Block.
Move Block.
Cut Block to Buffer.
Clear Block Markers.
Paste from Buffer.
Start of File.
End of File.
Insert Control Char.
Toggle Insert Mode.
Forwards Del. Char.
Start of Line.
End of Line.
Pageup.
Pagedown.
Cursor Up.
Cursor Down.
Cursor Left.
Cursor Right.
Define Macro.
Replay Macro.
Toggle case.
Move to word.
Back to word.
Scroll left.
Scroll right.
Undelete line.
Go to marked block.
Invalid Command. This means "ignore this keypress" - when creating
a keymapping, you can map to all keys to this function that are
not specifically mapped to any function, and this will prevent
junk from undefined keys being entered into the text.
Medit Bug Prize.
----------------
The prize of 1 beer (or alternative prize of equivalent value) still stands
for each new Medit bug reported to me.
Mark Taylor 27.2.2012