sources-request@mirror.UUCP (07/30/86)
Submitted by: ihnp4!pur-ee!pur-phy!duncan!lawrence Mod.sources: Volume 6, Issue 74 Archive-name: uEmacs3.7/Part04 [ This is the latest revision of one of two programs named "MicroEmacs"; when discussing these on the net, or in contacting the authors, make sure to mention the version number -- in this case 3.7 -- as that is the easiest way to distinguish between them. Daniel will be posting uuencoded executables in net.micro.pc and net.micro.amiga; the file 'readme' contains information on how to also get these from him directly. --r$ ] echo extracting - emacs.tut sed 's/^X//' > emacs.tut << 'FRIDAY_NIGHT' XYou are looking at the MICRO-EMACS tutorial. Comments on this document Xmay be refered to Dana Hoggatt or Dan Lawrance. X XEMACS commands generally involve the CONTROL key (sometimes labelled CTRL or XCTL) or the META key (generally labelled ESCAPE). Rather than write out META Xor CONTROL each time we want you to prefix a character, we'll use the following Xabbreviations: X X ^<chr> means hold the CONTROL key while typing the character <chr> X Thus, ^F would be: hold the CONTROL key and type F. X X ESC-<chr> means type the ESCAPE key and release it, then type the X character <chr>. The <chr> can be upper or lower case X and it will have the same meaning. X XImportant note: if you must exit at some point, type ^X ^C. X XThis tutorial attempts to help you "learn by doing". The characters ">>" Xat the left margin of your screen indicate directions for you to try using Xa command. For instance: X X>> Now type ^V (View next screen) to move to the next screen. X (go ahead, do it by depressing the control key and V together). X XFrom now on, you'll be expected to type ^V whenever you finish reading the Xcurrent screen. X XNote that there is an overlap when going from screen to screen; this Xprovides some continuity when moving through the file. X XThe first thing that you need to know is how to move around from place to Xplace in the file. You already know how to move forward a screen, with ^V. XTo move backwards a screen, type ^Z. (depress the CTRL key and type Z). X X>> Try typing ^Z and then ^V to move back and forth a few times. X X XSUMMARY X------- X XThe following commands are useful for viewing screenfuls: X X ^V Move forward one screenful X ^Z Move backward one screenful X <ESC>^L Clear screen and redisplay everything X putting the text near the cursor at the center. X X>> find the cursor and remember what text is near it. X Then type a <ESC>^L. X Find the cursor again and see what text is near it now. X X XBASIC CURSOR CONTROL X-------------------- X XGetting from screenful to screenful is useful, but how do you reposition Xyourself within a given screen to a specific place? There are several ways Xyou can do this. One way (not the best, but the most basic) is to use the Xcommands previous, backward, forward and next. As you can imagine these Xcommands (which are given to EMACS as ^P, ^B, ^F, and ^N respectively) move Xthe cursor from where it currently is to a new place in the given direction. XHere, in a more graphical form are the commands: X X Previous line, ^P X : X : X Backward, ^B .... Current cursor position .... Forward, ^F X : X : X Next line, ^N X XYou'll probably find it easy to think of these by letter. P for Xprevious, N for next, B for backward and F for forward. These are Xthe basic cursor positioning commands and you'll be using them ALL Xthe time so it would be of great benefit if you learn them now. X X>> Do a few ^N's to bring the cursor down to this line. X X>> Move into the line with ^F's and then up with several ^P's. X See what ^P does when the cursor is in the middle of the line. X XLines are separated by a single Linefeed character, which is what XUnix calls a Newline. X X>> Try to ^B at the beginning of a line. Do a few more ^B's. X Then do ^F's back to the end of the line and beyond. X XWhen you go off the top or bottom of the screen, the text beyond Xthe edge is shifted onto the screen so that your instructions can Xbe carried out while keeping the cursor on the screen. X X>> Try to move the cursor off the bottom of the screen with ^N and X see what happens. X XIf moving by characters is too slow, you can move by words. ESC-F X(Meta-F) moves forward a word and ESC-B moves back a word. X X>> Type a few ESC-F's and ESC-B's. Intersperse them with ^F's and ^B's. X XNotice the parallel between ^F and ^B on the one hand, and ESC-F and ESC-B on Xthe other hand. Very often Meta characters are used for operations related Xto English text whereas Control characters operate on the basic textual units Xthat are independent of what you are editing (characters, lines, etc). There Xis a similar parallel between lines and sentences: ^A and ^E move to the Xbeginning or end of a line. and ESC-A and ESC-E move to the beginning or end Xof a sentence. X X### Note: ESC-A and ESC-E are not implimented yet (DLH - 1/22/86) ### X X>> Try a couple of ^A's, and then a couple of ^E's. X Try a couple of ESC-A's, and then a couple of ESC-E's. X XSee how repeated ^A's do nothing, but repeated ESC-A's Xkeep moving farther. Do you think that this is right? X XTwo other simple cursor motion commands are ESC-< (Meta Less-than), Xwhich moves to the beginning of the file, and ESC-> (Meta Greater-than), Xwhich moves to the end of the file. You probably don't need to try Xthem, since finding this spot again will be boring. If you need the Xshift key to type a "<", then you must also use the shift key to type XESC-<. Otherwise, you would be typing ESC-, . X XThe location of the cursor within the text is also called "point". To Xparaphrase, the cursor shows on the screen where point is located in the text. X XHere is a summary of simple moving operations including Xthe word and sentence moving commands: X X ^F Move forward a character X ^B Move backward a character X X ESC-F Move forward a word X ESC-B Move backward a word X X ^N Move to next line X ^P Move to previous line X X ESC-N Move to next paragraph X ESC-P Move to previous paragraph X X ^A Move to beginning of line X ^E Move to end of line X X ESC-A Move back to beginning of sentence (not functional) X ESC-E Move forward to end of sentence (not functional) X X ESC-< Go to beginning of file X ESC-> Go to end of file X X>> Try all of these commands now a few times for practice. X Since the last two will take you away from this screen, X you can come back here with ^Z's and ^V's. These are X the most often used commands. X XLike all other commands in EMACS, these commands can be given Xarguments which cause them to be executed repeatedly. The way you Xgive a command a repeat count is by typing META and then the digits Xbefore you type the command. (Remember META is ususally called ESCAPE) X XFor instance, META 8 ^F moves forward eight characters. X X>> Try giving a suitable argument to ^N or ^P to come as close X as you can to this line in one jump. X XThis also applies to the screen moving commands, ^V and ^Z. When Xgiven an argument, they scroll the screen up or down by that many Xscreenfuls. As a special case, typing just ^U is equivalent to ESC-4. X X>> Try typing ESC-3 ^V now. X XIf you would like to scroll it down, you can give an argument to ^Z. X X XQUITTING FROM COMMANDS X---------------------- X XThe character in EMACS used to quit out of all commands which request Xinput is ^G. For example, you can use ^G to discard a numeric argument Xor the beginning of a command that you don't want to finish. X X>> Type ESC-100 to make a numeric arg of 100, then type ^G. X Now type ^F. How many characters does it move? X If you have typed an <ESC> by mistake, you can get rid of it X with a ^G. X X XIBM CURSOR KEYS X--------------- X XOn the IBM-PC version, the cursor keypad has been bound to some of the Xmore useful screen movement commands. The mappings are as follows: X X Cursor-Right ^F Move forward a character X Cursor-Left ^B Move backward a character X X ^Cursor-Right ESC-F Move forward a word X ^Cursor-Left ESC-B Move backward a word X X Cursor-Down ^N Move to next line X Cursor-UP ^P Move to previous line X X Pg-Dn ^V Move to next screen X Pg-Up ^Z Move to previous screen X X Home ESC-< Go to beginning of file X End ESC-> Go to end of file X X Insert ^O Open up a new line X Delete ^K Kill to end of line X XUsage of the ^O and ^K commands is described later in the tutorial. A Xmap of the key layout looks something like this: X X ------------------------------------------------- X | 7 | 8 | 9 | X | Home | ^ | Pg Up | X | | | | | X | ESC-< | ^P | ^Z | X ------------------------------------------------- X | 4 | 5 | 6 | X | <-- | | --> | X | | | | X | ^B | | ^F | X ------------------------------------------------- X | 1 | 2 | 3 | X | End | | | Pg Dn | X | | v | | X | ESC-> | ^N | ^V | X ------------------------------------------------------------- X | 0 | . | X | Insert | Delete | X | | | X | ^O | ^K | X ------------------------------------------------------------- X X>> if you have an IBM-PC, practice using the cursor keypad. X X X XERRORS X------ X XSometimes you may do something which EMACS doesn't allow. If it is Xsomething simple, such as typing a control key sequence which is not Xassociated with any command, EMACS will just beep at you. Otherwise, XEMACS will also display an informative error message at the bottom of Xthe screen. X XSome versions of EMACS do not have all the features described in this Xtutorial implemented yet. If you come across such an unimplemented Xfeature, you may get an error message when you try to use it. Just Xtype a space and proceed on to the next section of the tutorial. X X XINSERTING AND DELETING X---------------------- X XIf you want to type text, just do it. Characters which you can see, such Xas A, 7, *, etc. are taken by EMACS as text and are immediately inserted. XType <Return> (the carriage-return key) to insert a line separator. X XYou can delete the last character you typed by typing either <Delete> or ^H. XOn some keyboards, there is a dedicated key for creating a ^H. If so, it is Xusually labeled as either "Backspace" or "<--". <Delete> is a key on the Xkeyboard, which may be labeled "Rubout" instead of "Delete" on some terminals. XMore generally, <Delete> deletes the character immediately before the current Xcursor position. X X>> Do this now, type a few characters and then delete them by typing X <Delete> a few times. Don't worry about this file being changed; X you won't affect the master tutorial. This is just a copy of it. X X>> Now start typing text until you reach the right margin, and keep X typing. When a line of text gets too big for one line on the X screen, the line of text is "continued" off the edge of the screen X The dollar sign at the right margin indicates a line which has X been continued. EMACS scrolls the line over so you can see what you X are editing. The '$' at the left or right edge of the screen indicates X that the current line extends off in that direction. X X>> The following line actually goes off the edge. Trying typing enough ^F's X so that you move off the right hand end of this line. This is a long line of text. Note the "$"s at each edge. Keep typing ^F's and watch where EMACS decides to scroll the line. Now, type ^B's until EMACS decides to scroll the line again. X XThis is one of those gizmos which is easier to understand by playing with it Xthan by reading about it. X X>> Use ^D's or <Delete>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, in X which case it has a continuation indication. X X>> Type <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 Xthat this includes characters which insert themselves. X X>> Try that now -- type META 8 * and see what happens. X XIf you want to create a blank line in between two lines, move to the Xsecond of 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 XEMACS and correcting errors. You can delete by words or lines Xas well. Here 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 next character after the cursor 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 next word after the cursor 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 Xcharacter, but 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 that the difference between "Killing" and "Deleting" something Xis that "Killed" things can be yanked back, and "Deleted" things cannot. XGenerally, the commands that can destroy a lot of text save it, while the Xones that attack only one character, or nothing but blank lines and spaces, Xdo not save. X XFor instance, type ^N a couple times to postion the cursor Xat some line on this screen. X X>> Do this now, move the cursor and kill that line with ^K. X XNote that a single ^K kills the contents of the line, and a second X^K kills the line itself, and make all the other lines move up. If Xyou give ^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 Xretrieve it. To retrieve the last killed text and put it where Xthe cursor currently is, 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>> Do this now, type ^K several times. X XNow to retrieve that killed text: X X>> Type ^Y. Then move the cursor down a few lines and type ^Y X again. You now see how to copy some 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. X Then do ^Y to get back the second killed line. X X XFILES X----- X XIn order to make the text you edit permanent, you must put it in a file. XOtherwise, it will go away when you leave EMACS. While you are editing a Xfile in EMACS, your changes are actually being made to a private X"scratch" copy of the file. However, the changes still don't become Xpermanent until you "save" the file. This is so you can have control to Xavoid leaving a half-changed file around when you don't want to. X XIf you look near the botton of the screen you will see a line that Xlooks like this: X X =* MicroEMACS 3.1 (NORMAL) == emacs.tut == File: emacs.tut ========== X --------------- X XNote that EMACS indicates the name of the file you are currently editing. XThis is the name of your own temporary copy of the text of the EMACS Xtutorial; the file you are now editing. Whatever file you edit, that Xfile's name will appear in that precise spot. X XThe commands for finding and saving files are unlike the other commands you Xhave learned in that they consist of two characters. They both start with the Xcharacter Control-X. There is a whole series of commands that start with XControl-X; many of them have to do with files, buffers, and related things, Xand all of them consist of Control-X followed by some other character. As Xwith ESC, the character is interpreted the same regardless of case. X XAnother thing about the command for finding a file is that you have to say Xwhat file name you want. We say the command "reads an argument from the Xterminal" (in this case, the argument is the name of the file). After you Xtype the command X X ^X ^F Find a file X XEMACS will ask you for the file name. You should end the name with Xthe Return key. After this command, you will see the contents of the Xfile in your EMACS. You can edit the contents. When you wish to make Xthe changes permanent, issue the command X X ^X ^S Save the file X XA new version of the file will be created. When the operation is Xfinished, EMACS prints the name and number of lines saved. X XIf you forget to save and edit a different file and then decide to quit, XEMACS will remind you that you made changes that have not been save and Xthen ask you whether you really want to quit. (If you don't save them, Xthey will be thrown away. That might be what you want!) You should Xanswer with a "N" to save them or a "Y" to throw the changes away. X XTo make a new file, just edit it "as if" it already existed. Then start Xtyping in the text. When you ask to "save" the file, EMACS will really Xcreate the file with the text that you have inserted. From then on, you Xcan consider yourself to be editing an already existing file. X XIt is not easy for you to try out editing a file and continue with the Xtutorial. But you can always come back into the tutorial by starting it Xover and skipping forward. So, when you feel ready, you should try editing Xa file named "FOO", putting some text in it, and saving it; then exit from XEMACS and look at the file to be sure that it worked. X X XEXTENDING THE COMMAND SET X------------------------- X X### The mechanisms for extending the command set and setting ### X### the key bindings has not been installed yet. Skip forward ### X### to the next section (TEXT REPLACEMENT). DLH (1/22/86) ### X XThere are many, many more EMACS commands than could possibly be put Xon all the control and meta characters. EMACS gets around this with Xthe X (eXtend) command. This comes in two flavors: X X ^X Character eXtend. Followed by one character. X ESC-X Named command eXtend. Followed by a long name. X XThese are commands that are generally useful but used less than the commands Xyou have already learned about. You have already seen two of them: the file Xcommands ^X ^F to Find and ^X ^S to Save. Another example is the command to Xtell EMACS that you'd like to stop editing. The command to do this is ^X ^C. X XThere are many ^X commands. The ones you need immediately are: X X ^X ^F Find file. X ^X ^S Save file. X ^X ^C Quit EMACS. This does not save your files auto- X matically, though if your files have been modi- X fied, EMACS asks if you really want to quit. The X standard way to save and exit is ^X ^S ^X ^C. X XNamed eXtended commands are commands which are used even less Xfrequently, or commands which are used only in certain modes. These Xcommands are usually called "functions". An example is the function X"apropos", which prompts for a keyword and then gives the names of all Xthe functions that apropos for that keyword. When you type ESC-X, EMACS Xprompts you at the bottom of the screen with ":" and you should type the Xname of the function you wish to call; in this case, "apropos". Just Xtype "apr<Space>" and EMACS will complete the name. EMACS will ask you Xfor a keyword or phrase and you type the string that you want ask about. X X>> Try typing ESC-X, followed by "apropos" or "apr" and then Return. X Then try typing "file" followed by a Return. 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<Escape>altered<Escape>. X X Notice how this line has changed: you've replaced X the word c-h-a-n-g-e-d with "altered" wherever it occurs X after the cursor. X XThe more customary command for replacing strings is the interactive Xcommand query-replace-search, which has several options. In essence, it Xshows each occurance of the first string and asks you if you want to Xreplace it or not. You can also choose to edit around the string, or go Xon and replace all occurances without asking further. It is described in Xdetail in the EMACS manual. Also, typing a '?' when it asks you if you Xwish to replace will list out the various options. X X XMODE LINE X--------- X XThe bottom line of the screen is known as the communications line. This Xis where EMACS interactively communicates with you. You have already Xseen how emacs prompts you for information (like when searching). EMACS Xcan also report things to you as well. X X>> Type ^X = and see what you get in the communications line. X XThe line immediately above the communications line is called the MODE XLINE. The mode line says something like X X =* MicroEMACS 3.1 (NORMAL) == emacs.tut == File: emacs.tut ========== X XThis is a very useful "information" line. X XThe star means that you have made changes to the text. Right after Xyou visit or save a file, there is no star. X XThe buffername is the name EMACS gave to the buffer, and it is usually Xrelated to the filename. You already know what the filename means -- it Xis the file you have edited. X XThe part of the mode line inside the parentheses is to tell you what Xmodes you are in. The default mode is NORMAL which is what you are in Xnow. It is an example of a "major mode". There are several major modes Xin EMACS for editing different languages and text, such as C mode, Text Xmode, etc. At any time one and only one major mode is active, and its Xname can always be found in the mode line just where "NORMAL" is now. X XEach major mode makes a few commands behave differently. For example, Xthere are commands for creating comments in a program, and since each Xprogramming language has a different idea of what a should look like, Xeach major mode has to insert comments differently. Each major mode is Xcontrolled by a EMACS variable which can be manipulated and queried with Xthe "set" and "print" extended commands. X XMajor modes are called major because there are also minor modes. They Xare called minor because they aren't alternatives to the major modes, Xjust minor modifications of them. Each minor mode can be turned on or Xoff by itself, regardless of what major mode you are in, and regardless Xof the other minor modes. So you can use no minor modes, or one minor Xmode, or any combination of several minor modes. X XOne minor mode which is very useful, especially for editing English Xtext, is WRAP mode. When this mode is on, EMACS breaks the line in Xbetween words automatically whenever the line gets too long. You can Xturn this mode on by doing ^X M wrap <return>. When the mode is on, you Xcan turn it off by doing ^X ^M wrap <Return>. X X>> Type "^X ^M wrap <Return>" now. Then insert a line of "asdf " over X again until you see it divide into two lines. You must put in spaces X between them because Auto Fill breaks lines only at spaces. Note that X "WRAP" appears in the mode line, indicating that you are in WRAP mode. X XThe margin is usually set at 72 characters, but it can be shanged. XSimply type ESC nn ^X F, where "nn" is the column number for the right Xhand margin. 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 ESCAPE. X X>> Type ^S ESCAPE 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 XGETTING MORE HELP X----------------- X XIn this tutorial we have tried to supply just enough information to Xget you started using EMACS. There is so much available in EMACS that Xit would be impossible to explain it all here. However, you may want Xto learn more about EMACS since it has numerous desirable features Xthat you don't know about yet. X X### The on-line help features have not been implimented yet. DLH ### X XThe most basic HELP feature is the describe-key function which is Xavailable by typing ^X ? and then a command character. EMACS prints one Xline line on the bottom of the screen tell what function is bound to Xthat key. X XThe describe-command function ESC-? will prompt for the name of a function Xand print out the section from the manual about that command. When you Xare finished reading it, type a Space or a ^G (quit) to bring your text Xback on the screen. X X>> Type ^X ? Control-P. The message at the bottom of the screen should X be something like "^P is bound to previous-line". X XMulti-character commands such as ^X ^Z and <ESC>V are also allowed Xafter ^X ?. X XNow lets get more information about the previous-line command. X X>> Type ESC-? previous-line. When you are finished reading the X output, type a Space. X XThe "name of the function" is important for people who are customizing XEMACS. It is what appears in the EMACS CHART as the documentation for Xthe command character. X X XCONCLUSION X---------- X XRemember, to exit use ^X ^C. X XThis tutorial is meant to be understandable to all new users, so if Xyou found something unclear, don't sit and blame yourself - complain! X XYou'll probably find that if you use EMACS for a few days you won't Xbe able to give it up. Initially it may give you trouble. But remember Xthat this is the case with any editor, especially one that can do many, Xmany things. And EMACS can do practically everything. X X XAcknowledgements X---------------- X XThis is a modified version of the "JOVE Tutorial" by Jonathan Payne X(19 January 86). That document was in turn a modified version of the Xtutorial "Teach-Emacs" from MIT as modified by Steve Zimmerman at XCCA-UNIX (31 October 85). X XThis document was last updated on 2-7-86 by Dana Hoggatt. X FRIDAY_NIGHT echo extracting - emacs2.mss sed 's/^X//' > emacs2.mss << 'FRIDAY_NIGHT' X X@style(indent 8 chars, spacing 1 lines) X@begin(center) X@b(MicroEMACS 3.7) X X@i(Screen Editor) Xwritten by Dave Conroy Xand Daniel Lawrence X@end(center) X X X@begin(quotation) X This software is in the public domain and may be freely copied Xand used by one and all. We would ask that if it is incorporated into Xother software that proper credit be given to its authors. X@end(quotation) X X@flushleft(@b[Introduction]) X X MicroEMACS 3.7 is a screen editor for programming and word Xprocessing. It is availible for the IBM-PC and its clones, UNIX V7, XUNIX BSD4.2, UNIX V5, VMS, the HP150, the Wang-PC and the Commodore XAMIGA. It requires between 40 to 70K of space to run on these machines. XSome of its capabilities include: X X@begin(verbatim) X Multiple windows on screen at one time X X Multiple files in the editor at once X X Limited on screen formating of text X X User changable command set X X User written editing macroes X X Compatability across all supported environments X@end(verbatim) X X This manual is designed as a reference manual. All the commands Xin MicroEMACS are listed, in functional groups, along with detailed Xdescriptions of what each commands does. X@newpage X@flushleft(@b[How to Start]) X X MicroEMACS is invoked from the operating system command level Xwith a command of the form: X X@begin(verbatim) X emacs {options} <filelist> X Xwhere options may be: X X-v all the following files are in view mode (read only) X-e all the following files can be edited X-g<n> go directly to line <n> of the first file X-s<string> go to the end of the first occurance of <string> X in the first file X X@@<sfile> execute macro file <sfile> instead of the X standard startup file X Xand <filelist> is a list of files to be edited. X Xfor example: X X emacs @@start1.cmd -g56 test.c -v head.h def.h X X@end(verbatim) X X means to first execute macro file start1.cmd instead of the Xstandard startup file, emacs.rc and then read in test.c, position the Xcursor to line 56, and be ready to read in files head.h and def.h in Xview (read-only) mode. In the simple case, MicroEMACS is usually run by Xtyping: X X@flushleft( emacs <file>) X X where <file> is the name of the file to be edited. X@newpage X@flushleft(@b[How to type in commands]) X X Most commands in MicroEMACS are a single keystroke, or a Xkeystroke preceded by a command prefix. Control commands appear in the Xdocumentation like ^A which means to depress the <Ctrl> key and while Xholding down it down, type the A character. Meta-commands appear as XM-A which means to strike the Meta key (<ESC> on most computers) and Xthen after realeasing it, type the A character. Control-X commands Xusually appear as ^X-A which means to hold down the control key and type Xthe X character then type the A character. Both meta commands and Xcontrol-x commands can be control characters as well, for example, X^X-^O (the delete-blank-lines command) means to hold down <Ctrl>, type XX, keep holding down <Ctrl> and type the O character. X X Many commands in MicroEMACS can be executed a number of times. XIn order to make one command repeat many times, type Meta (<ESC>) Xfollowed by a number, and then the command. for example: X X@verbatim( M 12 ^K) X X will delete 12 lines starting at the cursor and going down. XSometimes, the repeat count is used as an argument to the command as in Xthe set-tab command where the repeat count is used to set the spacing of Xthe tab stops. X X@flushleft(@b[The Command List]) X X The following is a list of all the commands in MicroEMACS. XListed is the command name, the default (normal) keystrokes used to Xinvoke it, and alternative keys for the IBM-PC, and a description of Xwhat the command does. X X@begin(verbatim) X@b[(1) MOVING THE CURSOR] X X@i(previous-page) ^Z <Pg Up> X X Move one screen towards the begining of the file. X X@i(next-page) ^V <Pg Dn> X X Move one screen towards the end of the file. X X@i(begining-of-file) M-< <Home> X X Place the cursor at the begining of the file. X X@i(end-of-file) M-> <End> X X Place the cursor at the end of the file. X X@i(forward-character) ^F (6 on the keypad) X X Move the cursor one character to the right. Go down to Xthe begining of the next line if the cursor was already at the Xend of the current line. X X@i(backward-character) ^B (4 on the keypad) X X Move the cursor one character to the left. Go to the Xend of the previous line if the cursor was at the begining of Xthe current line. X X@i(next-word) M-F (^6 on the keypad) X X Place the cursor at the begining of the next word. X X@i(previous-word) M-B (^4 on the keypad) X X Place the cursor at the begining of the previous word. X X@i(begining-of-line) ^A X X Move cursor to the begining of the current line. X X@i(end-of-line) ^E X X Move the cursor to the end of the current line. X X@i(next-line) ^N (2 on the keypad) X X Move the cursor down one line. X X@i(previous-line) ^P (8 on the keypad) X X Move the cursor up one line. X X@i(goto-line) M-G X X Goto a specific line in the file. IE M 65 M-G would Xput the cursor on the 65th line of the current buffer. X X@i(next-paragraph) M-N X X Put the cursor at the first end of paragraph after the cursor. X X@i(previous-paragraph) M-P X X Put the cursor at the first begining of paragraph before the Xcursor. X X@b[(2) DELETING & INSERTING] X X@i(delete-previous-character) ^H <-- X X Delete the character immedietly to the left of the Xcursor. If the cursor is at the begining of a line, this will Xjoin the current line on the end of the previous one. X X@i(delete-next-character) ^D <Del> X X Delete the character the cursor is on. If the cursor is Xat the end of a line, the next line is put at the end of the Xcurrent one. X X@i(delete-previous word) M-^H M- <-- X X Delete the word before the cursor. X X@i(delete-next-word) M-^D X X Delete the word starting at the cursor. X X@i(kill-to-end-of-line) X X When used with no argument, this command deletes all Xtext from the cursor to the end of a line. When used on a blank Xline, it deletes the blank line. When used with an argument, it Xdeletes the specified number of lines. X X@i(insert-space) ^C <Ins> X X Insert a space before the character the cursor is on. X X@i(newline) <return> X X Insert a newline into the text, move the cursor down to the Xbegining of the next physical line, carrying any text that was after Xit with it. X X@i(newline-and-indent) ^J X X Insert a newline into the text, and indent the new line the Xsame as the previous line. X X@i(handle-tab) ^I --> X X With no argument, move the cursor to the begining of the Xnext tab stop. With an argument of zero, use real tab Xcharacters when tabbing. With a non-zero argument, use spaces Xto tab every argument positions. X X@i(delete-blank-lines) ^X-^O X X Delete all the blank lines before and after the current cursor Xposition. X X@i(kill-paragraph) M-^W X X Delete the paragraph that the cursor is currently in. X X@i(kill-region) ^W X X Delete all the characters from the cursor to the mark set with Xthe set-mark command. X X@i(copy-region) X X Copy all the characters between the cursor and the mark Xset with the set-mark command into the kill buffer (so they can Xlater be yanked elsewhere). X X@i(open-line) ^O X X Insert a newline at the cursor, but do not move the cursor. X X@b[(3) SEARCHING] X X@i(search-forward) ^S X X Seearch for a string from the current cursor position to Xthe end of the file. The string is typed on on the bottom line of Xthe screen, and terminated with the <ESC> key. Special characters Xcan be typed in by preceeding them with a ^Q. A single ^Q Xindicates a null string. On successive searches, hitting <ESC> Xalone causes the last search string to be reused. X X@i(search-reverse) ^R X X This command searches backwards in the file. In all other ways Xit is like search-forward. X X@i(incremental-search) ^X-S X X This command is similar to forward-search, but it processes the Xsearch as each character of the input string is typed in. This allows Xthe user to only use as many keystrokes as are needed to uniquely Xspecify the string being searched. Several control characters are active Xwhile isearching: X X ^S or ^X Skip to the next occurence of the current string X ^R skip to the last occurence of the current string X ^H back up to the last match (posibly deleting X the last character on the search string) X ^G abort the search, return to start X <ESC> end the search, stay here X X@i(reverse-incremental-search) ^X-R X X This command is the same as incremental-search, but it starts in Xthe reverse direction. X X@i(hunt-forward) unbound (<ALT>S on the IBM PC) X X This command repeats the last search with the last search string X X@i(hunt-backward) unbound (<ALT>R on the IBM PC) X X THe last search string is looked for starting at the cursor and Xgoing backwards. X X@b[(4) REPLACING] X X@i(replace-string) M-R X X This command allows you to replace all occurences of one string Xwith another string. The replacement starts at the current location of Xthe cursor and goes to the end of the current buffer. A numeric argument Xwill limit the number of strings replaced. X X@i(query-replace-string) M-^R X X Like the replace-string command, this command will replace one Xstring with another. However, it allows you to step through each string Xand ask you if you wish to make the replacement. When the computer asks Xif you wish to make the replacement, the following answers are allowed: X X Y Make the replacement and continue on to the next string X N Don't make the replacement, then continue X ! Replace the rest of the strings without asking X ^G Stop the command X . Go back to place the command started X ? get a list of options X X X@b[(5) CAPITALIZING & TRANSPOSING] X X@i(case-word-upper) M-U X X Change the following word into upper case. X X@i(case-word-capitalize) M-C X X Capitolize the following word. X X@i(case-word-lower) M-L X X Change the following word to lower case. X X@i(case-region-upper) ^X-^U X X Change all the alphabetic characters in a marked region to upper Xcase. X X@i(case-region-lower) ^X-^L X X Change all the alphabetic characters in a marked region to lower Xcase. X X@i(transpose-characters) ^T X X Swap the last and second last characters behind the cursor. X X@i(quote-character) ^Q X X Insert the next typed character, ignoring the fact that it may Xbe a command character. X X@b[(6) REGIONS & THE KILL BUFFER] X X@i(set-mark) M-<SPACE> X X This command is used to delimit the begining of a marked region. XMany commands are effective for a region of text. A region is defined Xas the text between the mark and the current cursor position. To delete Xa section of text, for example, one moves the cursor to the begining of Xthe text to be deleted, issues the set-mark command by typing M-<SPACE>, Xmoves the cursor to the end of the text to be deleted, and then deletes Xit by using the kill-region (^W) command. Only one mark can be set in Xone window or one buffer at a time, and MicroEMACS will try to remember Xa mark set in an offscreen buffer when it is called back on screen. X X@i(exchange-point-and-mark) ^X-^X X X This command moves the cursor to the current marked position in Xthe current window and moves the mark to where the cursor was. This is Xvery usefull in finding where a mark was, or in returning to a position Xpreviously marked. X X@b[(7) COPYING AND MOVING] X X@i(kill-region) ^W X X This command is used to copy the current region (as defined by Xthe current mark and the cursor) into the kill buffer. X X@i(yank) ^Y X X This copies the contents of the kill buffer into the text at the Xcurrent cursor position. This does not clear the kill buffer, and thus Xmay be used to make multiple copies of a section of text. X X@i(copy-region) M-W X X This command copies the contents of the current region into the Xkill buffer without deleting it from the current buffer. X X@b(8) MODES OF OPERATION] X X@i(add-mode) ^X-M X X Add a mode to the current buffer X X@i(delete-mode) ^X-^M X X Delete a mode from the current buffer X X@i(add-global-mode) M-M X X Add a mode to the global modes which get inherited by any new Xbuffers that are created while editing. X X@i(delete-global-mode) M-^M X X Delete a mode from the global mode list. This mode list is Xdisplayed as the first line in the output produced by the list-buffers Xcommand. X X@b( MODES) X X Modes are assigned to all buffers that exist during an editing Xsession. These modes effect the way text is inserted, and the operation Xof some commands. Legal modes are: X X X@i(OVER) Overwrite Mode X X In this mode, typed characters replace existing characters Xrather than being inserted into existing lines. Newlines still insert Xthemselves, but all other characters will write over existing characters Xon the current line being edited. This mode is very usefull for editing Xcharts, figures, and tables. X X@i(WRAP) Word Wrap Mode X X In this mode, when the cursor crosses the current fill column X(which defaults to 72) it will, at the next wordbreak, automatically Xinsert a newline, dragging the last word down with it. This makes Xtyping prose much easier since the newline (<RETURN>) only needs to be Xused between paragraphs. X X@i(VIEW) File Viewing Mode X X In this mode, no commands which can change the text are allowed. X X@i(CMODE) C Program Editing Mode X X This mode is for editing programs written in the 'C' programming Xlanguage. When the newline is used, the editor will attempt to place Xthe cursor at the proper indentation level on the next line. Close Xbraces are automatically undented for the user, and also pre-processor Xcommands are automatically set flush with the left margin. When a close Xparenthesis or brace is typed, if the matching open is on screen, the Xcursor briefly moves to it, and then back. (Typing any key will abort Xthis fence matching, executing the next command immediatly) X X@i(EXACT) Exact Case Matching on Searching MODE X X Normally case is insignificant during the various search Xcommands. This forces all matching to take character case into account. X X@i(MAGIC) Regular expresion pattern matching Mode X X This feature is not yet implimented. While it may be set as a Xmode, it will have no effect at the moment. When it is ready, it will Xcause all search commands to accept various pattern characters to allow Xregular exspression search and replaces. X X@b[(10) ON-SCREEN FORMATTING] X X@i(set-fill-column) ^X-F X X Sets the column used by WRAP mode and the fill-paragraph command. X X@i(handle-tab) <TAB> X X Given a numeric argument, the tab key resets the normal behavior Xof the tab key. An argument of zero causes the tab key to generate Xhardware tabs (at each 8 columns). A non-zero argument will cause the Xtab key to generate enough spaces to reach a culumn of a multiple of the Xargument given. This also resets the spacing used while in CMODE. X X@i(fill-paragraph) M-Q X X This takes all the text in the current paragraph (as defined by Xsurrounding blank lines, or a leading indent) and attempt to fill it Xfrom the left margin to the current fill column. X X@i(buffer-position) X X This command reports on the current and total lines and Xcharacters of the current buffer. It also gives the hexidecimal code of Xthe character currently under the cursor. X X@b[(11) MULTIPLE WINDOWS] X X@i(split-current-window) ^X-2 X X If possible, this command splits the current window into two Xnear equal windows, each displaying the buffer displayed by the original Xwindow. A numeric argument of 1 forces the upper window to be the new Xcurrent window, and an argument of 2 forces the lower window to be the Xnew current window. X X@i(delete-window) ^X-0 X X this command attempts to delete the current window, retrieving Xthe lines for use in the window above or below it. X X@i(delete-other-windows) ^X-1 X X All other windows are deleted by this command. The current Xwindow becomes the only window, using the entire availible screen. X X@i(next-window) ^X-O X X Make the next window down the current window. With an argument, Xthis makes the nth window from the top current. X X@i(previous-window) ^X-P X X Make the next window up the current window. With an argument, Xthis makes tghe nth window from the bottom the current window. X X@i(scroll-next-down) M-^V X X Scroll the next window down a page. X X@i(scroll-next-up) M-^Z X X Scroll the next window up a page. X X@b[(12) CONTROLLING WINDOWS] X X@i(grow-window) ^X-^ X X Enlarge the current window by the argument number of lines (1 by Xdefault). X X@i(shrink-window) ^X-^Z X X Shrink the current window by the argument number of lines (1 by Xdefault). X X@i(resize-window) ^X-W X X CHnage the size of the current window to the number of lines Xspecified by the argument, if possible. X X@i(move-window-down) ^X-^N X X Move the window into the current buffer down by one line. X X@i(move-window-up) ^X-^P X X Move the window into the current buffer up by one line. X X@i(redraw-display) M-^L X X Redraw the current window with the current line in the middle of Xthe window, of with an argument, with the current line on the nth line Xof the current window. X X@i(clear-and-redraw) ^L X X Clear the screen and redraw the entire display. Usefull on Xtimesharing systems where messages and other things can garbage the display. X X@b[(13) MULTIPLE BUFFERS] X X@i(select-buffer) ^X-B X X Switch to using another buffer in the current window. MicroEMACS Xwill prompt you for the name of the buffer to use. X X@i(next-buffer) ^X-X X X Switch to using the next buffer in the buffer list in the Xcurrent window. X X@i(name-buffer) M-^N X X Change the name of the current buffer. X X@i(kill-buffer) ^X-K X X Dispose of an undisplayed buffer in the editor and reclaim the Xspace. This does not delete the file the buffer was read from. X X@i(list-buffers) ^X-^B X X Split the current window and in one half bring up a list of all Xthe buffers currently existing in the editor. The active modes, change Xflag, and active flag for each buffer is also displayed. (The change Xflag is an * if the buffer has been changed and not written out. the Xactive flag is not an * if the file had been specified on the command Xline, but has not been read in yet since nothing has switched to that Xbuffer.) X X@i[(14) READING FROM DISK] X X@i(find-file) ^X-^F X X FInd the named file. If it is already in a buffer, make that Xbuffer active in the current window, otherwise attemt tocreate a new Xbuffer and read the file into it. X X@i(read-file) ^X-^R X X Read the named file into the current buffer (overwriting the Xprevious contents of the current buffer. If the change flag is set, a Xconfirmation will be asked). X X@i(insert-file) ^X-^I X X Insert the named file into the current position of the current Xbuffer. X X@i(view-file) ^X-^V X X Like find-file, this command either finds the file in a buffer, Xor creates a new buffer and reads the file in. In addition, this leaves Xthat buffer in VIEW mode. X X@i[(15) SAVING TO DISK] X X@i(save-file) ^X-^S X X If the contents of the current buffer have been changed, write Xit back to the file it was read from. X X@i(write-file) ^X-^W X X Write the contents of the current file to the named file, this Xalso changed the file name associated with the current buffer to the new Xfile name. X X@i(change-file-name) ^X-N X X Change the name associated with the current buffer to the file Xname given. X X@i(quick-exit) M-Z X X Write out all changed buffers to the files they were read from Xand exit the editor. X X@b[(16) ACCESSING THE OPERATING SYSTEM] X X@i(shell-command) ^X-! X X Send one command to execute to the operating system command Xprocessor, or shell. Upon completion, MicroEMACS will wait for a Xkeystroke to redraw the screen. X X@i(pipe-command) ^X-@ X X Execute one operating system command and pipe the resulting Xoutput into a buffer by the name of "command". X X@i(filter-buffer) ^X-# X X Execute one operating system command, using the contents of the Xcurrent buffer as input, and sending the results back to the same Xbuffer, replacing the original text. X X@i(i-shell) ^X-C X X Push up to a new command processor or shell. Upon exiting the Xshell, MicroEMACS will redraw its screen and continue editing. X X@i(suspend-emacs) ^X-D [only under BSD4.2] X X This command suspends the editing processor and puts it into the Xbackground. The "fg" command will restart MicroEMACS. X X@i(exit-emacs) ^X-^C X X Exit MicroEMACS back to the operating system. If there are any Xunwritten, changed buffers, the editor will promt to discard changes. X X@b[(17) KEY BINDINGS AND COMMANDS] X X@i(bind-to-key) M-K X X This command takes one of the named commands and binds it to a Xkey. From then on, whenever that key is struck, the bound command is Xexecuted. X X@i(unbind-key) M-^K X X This unbinds a command from a key. X X@i(describe-key) ^X-? X X This command will allow you to type a key and it will then Xreport the name of the command bound to that key. X X@i(execute-named-command) M-X X X This command will prompt you for the name of a command to Xexecute. Typing <SPACE> part way thought will tell the editor to Xattempt to complete the name on its own. If it then beeps, there is no Xsuch command to complete. X X@i(describe-bindings) UNBOUND X X This command splits the current window, and in one of the Xwindows makes a list of all the named commands, and the keys currently Xbound to them. X X@b[(18) COMMAND EXECUTION] X X Commands can also be executed as command scripts. This allows Xcomands and their arguments to be stored in files and executed. The Xgeneral form of a command script line is: X X <optional repeat count> {command-name} <optional arguments> X X@i(execute-command-line) UNBOUND X X Execute a typed in script line. X X@i(execute-buffer) UNBOUND X X Executes script lines in the named buffer. If the buffer is off Xscreen and an error occurs during execution, the cursor will be left on Xthe line causing the error. X X@i(execute-file) UNBOUND X X Executes script lines from a file. This is the normal way to Xexecute a special script. X X@i(clear-message-line) UNBOUND X X Clears the message line during script execution. This is Xusefull so as not to leave a confusion message from the last commands Xin a script. X X@i(unmark-buffer) UNBOUND X X Remove the change flag from the current buffer. This is very Xusefull in scripts where you are creating help windows, and don't want XMicroEMACS to complain about not saving them to a file. X X@i(insert-string) UNBOUND X X Insert a string into the current buffer. This allows you to Xbuild up text within a buffer without reading it in from a file. Some Xspecial characters are allowd, as follows: X X ~n newline X ~t tab X ~b backspace X ~f formfeed X X X@b[(19) MACRO EXECUTION] X X Also availible is one keyboard macro, which allows you to record Xa number of commands as they are executed and play them back. X X@i(begin-macro) ^X ( X X Start recording keyboard macro X X@i(end-macro) ^X ) X X Stop recording keyboard macro X X@i(execute-macro) ^X E X X Execute keyboard macro X X@i(store-macro) UNBOUND X X This command is used to store script lines in a hiffen buffer by Xthe name of "[Macro nn]" where <nn> is a number from 1 to 40 and Xcoresponds to the argument given this command. All script lines then Xencountered will be stored in this buffer rather than being executed. A Xscript line consisting of only "[end]" tells the editor that the macro Xis complete, and stops recording script lines in the buffer. X X@i(execute-macro-nn) UNBOUND [shift-<F1> thru shift-<F10>] X X This is the command to execute a script stored in one of the Xhidden macro buffers. On the IBM-PC the first ten of these are bound to Xshift-<F1> thru shift-<F10>. X@end(verbatim) FRIDAY_NIGHT echo es.4 completed! : That's all folks!