TOPS-10: The SOS text editor

In this post we'll look at the simple but powerful SOS text editor on TOPS-10.

Starting SOS

Type sos file.ext: if this is a new file SOS will print INPUT and put you in a mode where you can type lines. If it is an existing file it will print EDIT and you will be in command mode.

Inputting text

SOS will automatically assign numbers to each line which you will see on the left. You can type each line normally, making corrections using Delete, Control-U like on the command line. When you have finished inserting text, press Escape; SOS will print $ and return you to command mode.

SOS command format

At the * prompt, SOS accepts commands which are generally single letters followed by which lines to work on.

Command Meaning
p Prints around 16 lines around the current line
p . Prints just the current line
p 500 Prints line 500
p 600:700 Prints lines 600-700
p ^:* Print from first line to last line

Let's load up and print our hello world program from before.

.sos hworld.for
Edit: HWORLD.FOR
*p
00100		DO 1 J=1,5
00200	1	WRITE(5, 2)
00300	2	FORMAT(' HELLO, WORLD')
00400		END
*

Quick navigation

Once you select a line (eg via p 500 above) you can quickly move up and down by pressing Escape to move up one line and Control-J to move down one line; SOS will print the line it has moved to.

Replace, Insert, Delete

The R, I and D commands replace, insert and delete lines. Each take a line specification like above. R will prompt you to enter the new line to replace it. I will insert a line after the one you specified, giving it an appropriate line number. An example of changing our hello world program to print a different message twice:

*r300
00300	2	FORMAT(' GOODBYE, WORLD')
1 Lines (00300/1) deleted
*i100
00150		WRITE(5,2)
*p^:*
00100		DO 1 J=1,5
00150		WRITE(5, 2)
00200	1	WRITE(5, 2)
00300	2	FORMAT(' GOODBYE, WORLD')
00400		END

Exiting SOS

At the * prompt, type E to save and exit, ES to save without line numbers and exit, and EQ to exit without saving changes. Some programs do not accept line numbers hence the ES option; even if you do remove them, if you edit the file in SOS again it will add them back.

Those are all the commands you need to do most editing tasks. But read on for additional features that make life easier. Alternatively, you can type H at the prompt to view the help file.

Find and replace

The F command finds the next line with the specified text. You type F, then the text to find, then Escape and finally Return and it will print out the matching line. Note that SOS prints $ when you type Escape.

*fgoodbye$
00400	2	FORMAT('GOODBYE, WORLD')

After the Escape, but before the Return, you could also type a line number range.

To find the next instance of the same text, just type F on its own again.

To replace part of text without retyping the whole line, use the S command. Type S, the old text to replace, Escape, the new text and then Escape. You then must add a line range before pressing Return, so to replace on the current line you could use ..

00400	2	FORMAT('GOODBYE, WORLD')
*sGOODBYE$HELLO$.
00400	2	FORMAT('HELLO, WORLD')

Alter mode

This is a special mode where you can edit a line using interactive commands. Type A and your line number (or .) and SOS will print the line number. You can then type Space to move forwards one character, Delete to move back one character. SOS will print character by character as you do this navigation so you can see where you are.

D will delete the next character; I will allow you to insert text until you press Escape. Commands take prefixes to say how many characters to operate on.

In the example below I wanted to change HELLO to GOODBYE. I pressed Space until I got to the start of the word then pressed 5D to delete HELLO. I then pressed I, typed GOODBYE, then Escape, then finally Return to accept the rest of the line.

*p400
00400	2	FORMAT(' HELLO, WORLD')
*a.
00400	2	FORMAT(' \\HELLO\\GOODBYE, WORLD')

Quit-and-go, renumbering files

Instead of saving and exiting with E, you can type G and it will save and then execute (compile, load, run) the file - more precisely, it will remember the last command you ran and execute that. But this allows rapid edit-compile-run-edit loops.

The N command will renumber your lines - useful if you have done a lot of inserts into existing text.

There's more, such as the ability to take editing commands from a file and to cut/copy text to move it around the file: see the Reference Guide linked below for details.

Summary of commands

Command Meaning
A Alter mode
C Copy text
D Delete lines
E Save and exit
ES Save without line numbers, exit
EQ Exit without saving
F Find
G Save and execute
H Help
I Insert
J Join lines
Jc Justify lines
K Delete page mark
L List to line printer
M Set page mark
N Renumber lines
P Prints lines
R Replace lines
S Substitute text
T Cut text
V Case inversion
W Save, but do not exit.
X Extend (append) to a line

Further information

See the SOS User's Guide and the SOS Reference Manual on Bitsavers.

Questions, corrections, comments

I welcome any questions or comments, and also especially any corrections if I have got something wrong. Please email me at rupert@timereshared.com and I will add it here and update the main text.