There is a web-based editing system called"creweb" that lets you edit mud files from the interneton your browser. For more info on it: help creweb

But if you can't use creweb, then ed isthe default method for editing files inside the mud.ed is a simple editing program. It is designed towork on a line-by-line basis, so it is called a "line editor".

Let's start by looking at, and editing, a small file.We've coded a sword, and we want to change its descriptionfrom "short sword" to "plain sword":

1) I changed my working directory to my area weapons dir: cd /realms/cratylus/area/weap

2) I listed the contents of that dir: ls

3) I ran the ed command on the file sword.c: ed sword.c4) Within the editor, I issued the 'n' command. This makes the editor display line numbers next to the lines.

5) Within the editor, I issued the '1z' command. What 'z' does is display about 20 lines of the file (the exact number depends on your screen settings. In my case it's 22). If you happen to be looking at line 1, it will display lines 1 through to about 20. If you happen to be looking at line 40, it will display from line 40 to about 60. If you want to start looking at lines starting at line 15, you can issue the '15z' command, which basically means "display about 20 lines starting at line 15". In this case, I wanted to start from the beginning of the file, so I issued '1z'.

6) '1z' stopped listing the file at line 22, so I entered 'z' again to list the rest.

7) Since I want to change "short sword" to "plain sword", I examined each line to find the word "short". I noticed that line 15 has "short" in it, so to get a look at that line alone, I entered '15'.

8) Now that I'm sure line 15 needs to change, I issue the '15c' command. 'c' indicates that I want to change a line. '15c' means "delete whatever was in line 15, and replace it with what I am about to type".

9) You can see that my editor prompt changed from ":" to "*". What this means is that I am now in "input mode". Whatever I type now will be added to the file. Since my last command in "command mode" was '15c', I am now replacing that line with what I want the line to contain:SetKeyName("plain sword");

10) Ok, I replaced the line, but I'm still in input mode. To go back to command mode, I type a single period and enter, like this:.

11) I'm back in command mode now. When I list the file contents with '1z' I can see that line 15 now says what I wanted.

12) Now I see another line that needs changing, so I enter '18' to get a closer look.

13) Sure enough, 18 needs to change, so I issue '18c'.

14) Like I did for line 15, I enter what the line should be.

15) To return to command mode, I enter a single period on a blank line.

16) I list the file contents, and see that my change was successful.

17) I'm finished making my changes, so I issue the 'x' command. 'x' means "save the changes I have made, and exit the editor".

18) I am now at my regular command prompt. To load my changes to this file, I type 'update sword'.

Editor basics, part 2

In the last section you saw what a simple linereplacement looks like in ed. Next we'll talk about some commoned actions.

ADDING STUFF:

Suppose I want to specify that this sword requires onlyone hand to wield it:

Here you can see that instead of 'c', which replaces, Iused 'a', which adds. I decided my new line would go after line20, so I issued the command '20a'. Once I was done, I typeda single dot on a blank line to exit "input mode". You'll noticeI didn't use the 'z' command. Instead, since I knew where mychanges would go, I decided to list lines 18 through 22 withthe command '18,22'. I then issued the 'x' command to save my changes and exit the editor. If had I wanted my addition to go in front of line 20, I could have used the '20i' command.

DELETING LINES

Suppose I'm tired of seeing header lines that nolonger apply to this file. We can delete a single line, ora range of lines, with the 'd' commmand:

First I deleted lines 1 through 5 with the command '1,5d'. Then, for good measure, I removed the remaining blank line '1d'. Voila. Cleaner code.

REPLACING STRINGS

Well now I want to replace all instances of "short" with"plain", and I don't feel like editing each matching linemanually. I can do a search and replace. First I will list whichlines need to change, then I will change them:

The command g/short/p showed me all the linesthat contained the substring "short". Then I ran the globalsearch and replace command to substitute "plain" for "short",:g/short/s/short/plain Then I searched again for the string "short" andnothing came up, because it had been replaced.

Finally I went to line number 1 and issued the 'I'command. This auto-indents the code, making it neater andeasier to read.

Editor basics, part 3

Now let's look at some common problems:

1) Accidental deletion

If you type 1,20d when you meant to type 1,2d you will endup with a file 18 lines shorter than you intended. ed does nothave an "undo" command, so those lines will never come back. However, if you quit the editor *without saving*, then thatdeletion will not be committed to the file. You can issue the 'Q'command:

:Q

To force quit without saving. Of course, if those linesweren't already in the file, this won't help much.

2) Can't leave the editor

You try to write and exit, but get this:

:xFile command failed.

What this means is that for some reason, you can't writeto the file, so you don't exit the editor. What this usually means is thatyou tried to edit a file that does not belong to you. Since you do nothave permission to modify the file, ed refuses to commit your changes.

There are two ways around this. If you don't really carewhether your changes are saved or not, you can just force quit the editor with 'Q':

:QExit from ed.

Your changes will be lost, but you'll be out of the editor.

If you really want to save this file, you'll have to save itsomewhere other than your current working directory (cwd). You can saveit to your home directory with the 'w' command, then force quit:

This is pretty self explanatory. Indent relies on a certain amount of coherence in your code, and if your syntax is sufficientlymunged, it can't figure out how to properly do its thing. Examine the line that indent complains about, and also theline before it. Sometimes a good line is accused of being bad, justbecause it comes after a bad line.

4) I need to [something] in ed, but don't know how!

While in command mode, type 'h' and enter. You'll geta handy list of ed commands available to you.

5) My ability/patience/time is limited. I want not to use ed.

I feel your pain. The currently available ways aroundthis are:

1) Shell account. If you can get shell, or command line accessto the computer that is running the mud, then you can probablyuse an editor local to that computer (like vim) to edit files. Chances are, though, that if you are a regular rank-and-filecreator, you will not be given shell access. Most system adminsconsider giving random people off the net shell access an abomination.

2) Server FTP/SFTP. The server that runs the mud might have anftp server or sftpd access. Again, most security-conscious sysadminswill not permit Just Some Person Off The Internet to have thiskind of access.

3) Mud FTP. I don't like this option. Unix FTPD is a security concern as it is. Using unsupported, un-warrantied mud network codeto provide ftp access to files seems to me to be equivalent to pullingdown your pants, bending over, and whistling for the Internet tocome visit. But...it's an option.

4) Client upload. This is actually the most sensible option, ifyou are truly allergic to ed. You still need to use ed, but whatyou can do is write your code in your favorite local editor, like notepad or gvim or whatever. Then use your mud client (most of themhave an option to "send text") to send the code by running ed,entering input mode, copying the code from your editor, andpasting it into your client. This is a somewhat awkward system, and ill-suited to making minor changes. But it has the virtue of working well andbeing a widely available option.

5) Suck it up. Really, you need to just get used to it. Don'tmake me tell you stories about how when I was younger I had tocode using a VT terminal with no cut-and-paste, in an unheated,locked computer lab 20'x10' in size, at 9600 bps. In a snowstorm.Uphill both ways.