X - The asterisk (star) indicates that changes have been made to the file.
X Immediately after opening or saving a file, there is no star.
X
X - Any words inside the parentheses indicate the "modes" EMACS is
X currently in. Modes will be discussed in the next section.
X
X - The string following the () is the buffername, i.e., the name EMACS
X gives to the buffer, and it is usually related to the filename.
X
X - The string following "File:" is the name of the file you are
X currently editing.
X
X>> Look at the mode line and identify the items discussed above.
X
X
XMODES
X-----
X
XListed within the parentheses are the "modes" which are associated with
Xthe current buffer. Modes are a feature of EMACS which assist in the
Xediting of different languages, i.e., C, and text. Presently, there are
Xno modes associated with this buffer. This means EMACS will do exactly
Xwhat you think it will when using it - no "bonuses". You can find out
Xmore about the current buffer and mode status by typing ^X^B. Refer to
Xthe EMACS manual for a further discussion of buffers and modes.
X
XAs you become more familiar with EMACS and the use of buffers, "mode"
Xtakes on additional meaning. When more than one buffer is in use, a
Xmode is referred to as "local" or "global". These terms indicate how a
Xmode will affect the current buffer and other existing or to be added
Xbuffers.
X
XA "local" mode is valid only within the scope of the current buffer.
XOther existing buffers and buffers which will be added are not affected
Xby local modes.
X
XThe commands to add and delete local modes are
X
X ^XM Add a local mode
X ^X^M Delete a local mode
X
XEach of the above commands will prompt you for a mode. To activate
X(deactivate) a mode, type the name of a valid (active) mode (refer to
XEMACS manual for a complete list of the valid modes) and follow it by
Xpressing <Return>, the carriage-return key.
X
X>> Type ^XM WRAP - note the change in the mode line. Move the cursor
X to a blank line on this screen and begin typing the sequence "asdf ".
X Continue typing this sequence and note what happens when the right
X margin is encountered.
X
XThe previous exercise allowed you to enter text with the "WRAP" mode
Xactive. As you can see, "WRAP" instructs EMACS to break between words
Xwhen a line gets too long. However, in order for this mode to be
Xeffective, spaces must be inserted between words.
X
XThe right margin is usually set at 72 characters but it can be changed.
XTo change the margin type ESC nn ^XF where "nn" is the column number of
Xthe new right-hand margin.
X
X>> Type ESC 40 ^XF. Then begin typing "asdf " and notice where the
X line now breaks. To return to the default right-hand margin, type
X ESC 72 ^XF.
X
X>> Type ^X^M WRAP to "turn off" the local mode "WRAP".
X
XA "global" mode affects only those buffers which will be ADDED after the
X"add/delete global mode" command is executed - not the current or other
Xexisting buffers. Currently there is no global mode set.
X
XThe commands to add and delete global modes are
X
X ESC-M Add a global mode
X ESC-^M Delete a global mode
X
XNote: All modes can be local. However, global modes allow you to
X activate those modes which usually apply to most of the buffers
X in use.
X
XAs with local modes, each of the above commands will prompt you for
Xa mode. To activate (deactivate) a mode, enter the name of a valid
X(active) mode.
X
X>> Type ESC-M OVER. This mode tells EMACS to write over the text on
X the current line. Is there any change in the mode line? Now move to
X the line of "asdf " you entered and start typing. Note that nothing
X happens. Remember that global modes affect only those modes which
X will be added - not those already existing.
X
X>> Type ESC-^M OVER to "turn off" the global overwrite mode.
X
X
XINSERTING AND DELETING
X----------------------
X
XIf you want to type text, just start typing. Characters which you
Xcan see, such as A, 7, *, etc. are taken by EMACS as text and are
Ximmediately inserted. Type <Return> to insert a line separator,
Xi.e., a single linefeed character.
X
XYou can delete the last character you typed by typing either <Delete>
Xor ^H. On some keyboards, there is a dedicated key for creating a ^H.
XIf so, it is usually labelled as either "Backspace" or "<--". <Delete>
Xis a key on the keyboard, which may be labelled "Rubout" instead of
X"Delete" on some terminals. More generally, <Delete> deletes the
Xcharacter immediately before the current cursor position.
X
X>> Now type a few characters and then delete them by typing <Delete>
X a few times.
X
X>> Now start typing text until you reach the right margin, then continue
X to type. When a line of text gets too big for one line on the screen,
X the line of text is "continued" off the edge of the screen. The dollar
X sign at the right margin indicates a line which has been continued.
X EMACS scrolls the line over so you can see what you are editing. The
X "$" at the left or right edge of the screen indicates that the current
X line extends off in that direction.
X
XThis concept is easier to understand by doing rather than by reading about
Xit so it is suggested that the following exercises be done.
X
X>> The following line actually goes off the edge. Try typing enough ESC-F's
X so that you move off the right hand end of this line. This is a long line of text. Note the "$" at each edge. Keep typing ESC-F's and watch where EMACS decides to scroll the line. Now, type ESC-B's until EMACS decides to scroll the line again.
X
X>> Go to the line you entered which the text continued off the edge of
X the screen. Use ^D's to delete the text until the text line fits on
X one screen line again. The continuation "$" will go away.
X
X>> Move the cursor to the beginning of a line and type <Delete>. This
X deletes the line separator before the line and merges the line onto
X the previous line. The resulting line may be too long to fit on the
X screen, in which case it has a continuation indicator.
X
X>> Press <Return> to insert the separator again.
X
XInternally, EMACS will allow you to have lines of nearly any length, limited
Xonly by the amount of memory available. Externally, however, EMACS can only
Xread or write lines, to or from a file, which are less than or equal to 255
Xcharacters.
X
XRemember that most EMACS commands can be given a repeat count. Note that
Xthis includes characters which insert themselves.
X
X>> Try that now -- type ESC-8 * and see what happens.
X
XIf you want to insert spaces in a line, type ^C.
X
X>> Move to a line and move the cursor with ^F's; then insert spaces with ^C.
X Use ^D to remove the spaces.
X
XIf you want to create a blank line between two lines, move to the second
Xof the two lines and type ^O.
X
X>> Try moving to a line and typing ^O now.
X
XYou've now learned the most basic way of typing something in EMACS and
Xcorrecting errors. You can delete characters, words or lines as well.
XHere is a summary of the delete operations:
X
X <Delete> Delete the character just before the cursor
X ^H Delete the character just before the cursor
X ^D Delete the character the cursor is under
X
X ESC-<Delete> Kill the word immediately before the cursor
X ESC-^H Kill the word immediately before the cursor
X ESC-D Kill the word from the cursor position
X
X ^K Kill from the cursor position to end of line
X
XNotice that <Delete> and ^D vs ESC-<Delete> and ESC-D extend the parallel
Xstarted by ^F and ESC-F (well, <Delete> isn't really a control character,
Xbut let's not worry about that).
X
XNow suppose you kill something, and then you decide that you want to get
Xit back? Well, whenever you kill something bigger than a character, EMACS
Xsaves it for you. To yank it back, use ^Y. Note that you don't have to
Xbe in the same place to do ^Y. This is a good way to move text around.
XAlso note the difference between "Killing" and "Deleting" - "Killed" text
Xcan be yanked back, and "Deleted" text cannot. Generally, the commands
Xthat can destroy a lot of text save it, while the ones that attack only
Xone character do not save it.
X
X>> Type ^N a couple times to position the cursor at some line on this
X screen. Now kill that line with ^K.
X
XNote that a single ^K kills the contents of the line, and a second ^K
Xkills the line itself, and makes all the other lines move up. If you
Xgive ^K a repeat count, it kills that many lines AND their contents.
X
XThe text that has just disappeared is saved so that you can retrieve it.
XTo retrieve the last killed text and put it where the cursor currently
Xis, type ^Y.
X
X>> Try it. Type ^Y to yank the text back.
X
XThink of ^Y as if you were yanking something back that someone took away
Xfrom you. Notice that if you do several ^K's in a row the text that is
Xkilled is all saved together so that one ^Y will yank all of the lines.
X
X>> Try it. Type ^K several times.
X
X>> To retrieve that killed text: Type ^Y. Move the cursor down a few
X lines and type ^Y again. You now know how to copy text.
X
XWhat do you do if you have some text you want to yank back, and then
Xyou kill something else? ^Y would yank the more recent kill.
X
X>> Kill a line, move around, kill another line. Then do ^Y to get back
X the second killed line.
X
X
XSEARCHING
X---------
X
XEMACS can do searches for strings (these are groups of contiguous
Xcharacters or words) either forward through the file or backward
Xthrough it.
X
X>> Now type ^S to start a search. Type the word "cursor", then ESC.
X
X>> Type ^S ESC to find the next occurrence of "cursor".
X
XThe ^S starts a search that looks for any occurrence of the search
Xstring AFTER the current cursor position. But what if you want to
Xsearch for something earlier in the text? To do this one should
Xtype ^R for Reverse search. Everything that applies to ^S applies
Xto ^R except that the direction of the search is reversed.
X
X
XTEXT REPLACEMENT
X----------------
X
X>> Move the cursor to the blank line two lines below this one.
X Then type ESC-R changed ESC altered ESC .
X
X Notice how this line has changed; you have replaced the word
X "changed" with "altered" wherever it occurs in the file after
X the cursor. After all the substitutions have been made or
X the end of file has been reached, a message informing you of
X the number of substitutions which have been made appears in
X the communication line.
X
XThe more customary command for replacing strings is the interactive
Xcommand query-replace-search (ESC-^R), which has several options. In
Xessence, it shows each occurrence of the first string and asks you if
Xyou want to replace it or not. Type a "?" when it asks to replace the
Xstring to list the various options for query-replace-search. For a
Xmore detailed discussion of this command refer to the EMACS manual.
X
X
XFILES
X-----
X
XIn order to make the text changes permanent, you must save them to a file.
XIf you do not save them, the changes will "disappear" when you leave EMACS.
XAs you make changes, i.e., corrections, deletions, insertions, etc., they
Xare actually written to a "scratch" copy of the file and the changes to
Xthis file will not affect the "master" copy of the file until a file save
Xis specified. This allows you to decide if changes made to the file should
Xbe made permanent or discarded.
X
XRemember: The file name appears on the mode line.