Starting Emacs to Edit a File

Before you start the next section, you should copy the file ‘stories’ into your directory. Type the following to copy the file.

hostname{~}% cp ~csci203/examples/stories stories

To run Emacs, type at a hostname % prompt the command emacs followed by a file name and ‘&’. To create the new file named myfile type the following:

hostname{~}% emacs myfile &

The & sign tells UNIX that you wish to run this program in the “background”. Basically, what this does is give you the host-name % prompt back to allow you to issue others commands in the window.

Since you probably don't have a file called ‘myfile’ in your directory, Emacs creates a new file. You should see ‘(New file)’ at the bottom of the window. Notice the black bar near the bottom. It should tell you the name of the file, the time and other information. And the black rectangle in the upper left hand corner of the Emacs window. This ‘cursor’ moves along as you type. It is important for you to distinguish between the mouse pointer and the cursor. The pointer is used to move between windows and to select items to click on. The cursor is where you type text. Each Emacs and host-name % window has a cursor. The cursor is a black rectangle when the window is active and white when not active.

Now you are ready to edit the file. With the mouse pointer in the large area of the window, start typing. Don't worry about making mistakes. We will fix them up in a few moments. Type three or four lines worth of text. Use the four arrow keys (on far right side of Sun's keyboard) to move the cursor around and insert text. Make corrections by deleting the character to the left of the cursor by using the Backspace key. You can also use the left mouse button to position the cursor where the pointer is.