[ previous ] [ Abstract ] [ Copyright Notice ] [ Contents ] [ next ]

Simple editor for X: Users' Guide
Chapter 2 Short tutorial


2.1 Starting SeX

If SeX has been installed properly, it can be from a Unix command line by using the command sex. This will start SeX with no files loaded. You can load files later by using the File menu. You can also load files directly from the command line, by giving their names after the name of the program:

     sex letter.txt

The above command would load the file letter.txt into the editor. You can load as many files as you wish, from the command line, via the File menu, or in any combination. SeX does not limit the number of files that are loaded. SeX does not have any command line options.

The window has a menu bar at the top, a large text area in the middle, scroll bars below and to the right of the text area, and a status line at the bottom. The status line shows the current position in the text, and the total size of the text. When the file has been modified but not yet saved, the end of the status line will have two stars.


2.2 Typing new text

To insert new text, you just type. There is no special command you need to use. SeX is `eight bit clean', meaning that non-English letters will usually work, at least for West European languages.

If you have selected text (this is explained in the next two sections), typing something will replace the selection.


2.3 Selecting text with the mouse

The greatest appeal of SeX is what it allows you to do with a mouse, its mouse language. If you've used X a lot, you are probably familiar with xterm. SeX defines the following mouse language:

  1. Left mouse button selects text. Painting: you move the mouse to one end of the text to be selected, press the left button, move the mouse to the other end, and release the button. Clicking: Clicking twice selects the word under the mouse cursor, and thrice selects the line. You can combine painting and clicking: if you replace the second or third click with a paint, the painting will be done in units of words or lines.
  1. Right mouse button changes the selection. It moves the nearest end of the selection to the cursor.
  1. The middle mouse button cuts or pastes text. If the mouse cursor was inside the selection, then the selection is cut: removed from the text and put into the kill ring. If the mouse cursor was outside the selection, the selection is pasted (inserted into the text) at the location of the cursor.

The way SeX uses the middle mouse button is unique to SeX, and makes it really easy to delete and move text around, which is what most editing is.

The selection is shown with black background. There is no separate text cursor: the selection is the text cursor.

The selection may be columnar, i.e., a rectangle that selects only between the columns of the end points. The shape of the selection is controlled with the Toggle columnar entry in the Edit menu.

SeX defines some more things that can be done with the mouse, but they will be described later.


2.4 Selecting text with the keyboard

The empty selection can be moved around with the cursor keys, as usual. Some Emacs key bindings also work; see Command summary, Chapter 4. If the selection was not empty, it will be made empty, by selecting the empty string at either end of the selection.

Non-empty selections can be made by pressing Shift and a cursor key. This moves one end of the selection, and keeps the other end at the same place. For example, pressing Shift-Right twice, selects the next two characters. Pressing Control-Shift-Right selects the next two words.


2.5 Editing text

When you have selected text, you can cut it, by clicking inside the text with the middle mouse button. This will remove the selected text from the file, and put it into a kill ring (sort of like a clipboard). If you then move to some other place, you can paste the text from the kill ring, again by clicking with the middle mouse button. This is a simple way to move text around in the text.

The kill ring is different from a traditional clipboard in that it can contain many pieces of text. After you have pasted the first piece of text in the ring, you can replace the pasted text with the next piece of text, by pressing the control key while you click the middle mouse button. And then you can replace that with the next piece. After the last piece of text, you get the first piece again (that's why it's a ring). You can do this any number of times. This is useful when you know you regret having deleted text some time ago, and would like to get it back.

Instead of cutting the selected text, you can paste it directly by just clicking with the middle mouse button outside the selection. Copying is as simple as moving.

You can also cut, copy, and paste with the keyboard. Delete cuts, Alt-W copies, Insert pastes the most recent text in the kill ring, and Control-Insert goes round in the kill ring. Further key bindings are shown in Command summary, Chapter 4.

The Edit menu allows you to do the editing without having to memorize anything. It is just somewhat slow.


2.6 Using files

The File menu allows you to operate on files:

New
Create a new buffer. A buffer is the in-memory version of a file. The new buffer is empty, and does not have name.
Load
Load a file into memory, into a new buffer.
Save
Save buffer to disk. Any modifications you make to a buffer will vanish when you quit SeX, unless you save them first. SeX warns you if you try to quit without saving.
Save as
Save buffer to a new file. This changes the name of the buffer. If you load file A, edit it, and save it as B, then the disk will have two files, A and B, but only B will have the edits.
Save all modified
Save all buffers that have not been changed. If you work on many files at the same time, use this to save all of them, so that you don't have to go through all files and save them one by one.
Insert file
Insert the contents of a new file into the current one.
Write selection to
Write the selected text to a file.
Remove buffer
Forget everything about a buffer. This does not remove the actual file from the disk, only the in-memory version of it. You can't remove a modified buffer, but see the next entry.
Mark unmodified
Forget that a buffer has been modified. The changes will remain, but SeX will clear the `modified' flag for the file. This lets you remove the buffer without saving the changes.
Next file
Show the next file in this window. If you have many files loaded at the same time, this moves to the next one. The files are in a ring, so you can go through all of them until you get back to the one you started with.
Previous file
Move backwards through the ring of files.
Exit
Commence celibacy.


2.7 Searching and replacing

The Search menu allows you to search, and optionally replace text in a file. The first entry in the menu pops up the search and replace dialog box. The other entries are alternative ways to select the command buttons in the dialog box.

The dialog box has two text fields, for the text to search for, and the text to replace it with. There are also option buttons for backwards searching (default is forwards), case insensitive matching (makes `a' match `A'), and regular expressions (a powerful way to write complicated patterns; see regex(7)).

In the replacement text, you can use & to include the matched text. For example, if the search pattern matches foo in the text, and the replacement text is &bar, the text will be modified to be foobar. To get & itself, you need to type \& (and \\ to get a backslash; no other escapes work, however).

The command buttons are:

Search next
Search the next place where the search text occurs.
Replace+search
Replace this occurence of the search text with the replacement text, and then search again.
Replace this
Just replace this occurence.
Replace all
Replace this and all other occurences.
Reset
Make the search and replacement texts empty, and select the default values for the options.
Dismiss
Close the dialog box.

The dialog box will stay visible until you close it.


2.8 Using multiple windows

SeX allows as many windows as you wish. You can have any number of windows displaying the same file, or a different file in each window. Windows are created using the Window menu:

Clone
Create a new window, which is a clone of the current window. The new window will show the same file at the same place, but will not have the same selection, since only one window at a time can have a non-empty selection.
Every file
Open a new window for every file that does not already have its own window.
Close this
Close a window.
Close others
Close all other windows.

Note that every SeX window is a different top level window (which means, for example, that you can iconify them separately). SeX does not divide its top level windows into subwindows.


[ previous ] [ Abstract ] [ Copyright Notice ] [ Contents ] [ next ]
Simple editor for X: Users' Guide
Version 0.12
Lars Wirzenius liw@iki.fi