demon's gate

Shard's ed Survival Guide

Introduction

First of all, ed is the little program that provides the primary way for a mud wizard to edit files on DG (and most any other LPMud for that matter). In practice it will probably be your last resort, something to use when you absolutely can't get access to ftp or copy & paste.
To use ed you type 'ed filename'. For example to edit a file called myfile.c in your current directory type 'ed myfile.c'. One of 2 things will then happen. If the file exists in your current directory, it will be opened in ed, ready for you to hack. If it does not exist, it will be created and you'll get a message like this ...

Opening ed with file: /d/Pegana/shard/myfile.c
'd/Pegana/shard/myfile.c' isn't readable.
:

The colon on the last line is the 'command prompt' in ed .. it means ed is waiting for you to give one of its commands. The other prompt in ed is a simple period. The period prompt means you are in 'edit mode' and anything you type will be added to the file at the appropriate line number. To get out of edit mode, and back into command mode type a period by itself on a line when you are in edit mode. This will allow you to once again enter such useful commands as 'Q' for Quit.
Note that when you are using ed to edit a brand new file, you must give the 'a' command first before you can type any lines of code. 'c' and 'i' won't work since the new file has no lines.

The Most Important Thing About Ed!

Don't use it if you can possibly avoid it. FTP is much nicer.

Essential Commands

The following are the most commonly used and most useful commands. Although life might certainly be easier if you learn some other commands, you can get by with these alone. Probably.
Remember the following mnemonics and you'll be ok ..
a for append
c for copy over
i for insert above
x for exit and save
d for delete
n for number the lines
z for list (sorry about that last one).
Also you should know how to set your current line number. It's easy, just type the number of the line you want to go to at the command prompt. Further commands will relate to the line you are on. For example if you type '32' to place yourself on line 32, and then 'c' to copy over the current line, then any text you type will replace what was previously on line 32.

Command: a Usage: a
Append causes the editor to enter input mode, inserting all text starting AFTER the current line. Use a '.' on a blank line to exit this mode.

Command: c Usage: c
Change command causes the current line to be wiped from memory. The editor enters input mode and all text is inserted where the previous line existed.

Command: d Usage: d or [range]d
Deletes the current line unless preceeded with a range of lines, then the entire range will be deleted.

Command: i Usage: i
Insert causes the editor to enter input mode, inserting all text starting BEFORE the current line. Use a '.' on a blank line to exit this mode.

Command: q Usage: q
Quit the editor. Note that you can't quit this way if there are any unsaved changes. See 'w' for writing changes to file.

Command: Q Usage: Q
Force Quit. Quit the editor even if the buffer contains unsaved modifications.

Command: n Usage: n
This command toggles the internal flag which will cause line numbers to be printed whenever a line is listed.

Command: x Usage: x
Save file under the current name, and then exit from ed.
Command: z Usage: z or z- or z.
Displays 20 lines starting at the current line. If the command is 'z.' then 20 lines are displayed being centered on the current line. The command 'z-' displays the 20 lines before the current line.

Command: Z Usage: Z or Z- or Z.
Displays 40 lines starting at the current line. If the command is 'Z.' then 40 lines are displayed being centered on the current line. The command 'Z-' displays the 40 lines before the current line.

All The Commands

The following list is really just the output from typing 'h' at the command prompt while in ed's command mode. These are all the documented commands you can use in ed.
demonsgate mud