XEmacs: Editing Under UNIX
This chapter explains how to use the XEmacs text editor to manipulate and change files created using XEmacs. Essentially everything here also applies to GNU Emacs, which you might find on other sites.
There are other editors online, of course, including the venerable vi. You should look at both XEmacs and vi carefully. Much of your future life will be spent working with a text editor, so you should find one that you find natural and convenient.
Introduction to XEmacs
The editor you will be using is called XEmacs. It is an advanced, self-documenting real-time display editor. We say that XEmacs is a real-time display editor because the text being edited is visible on the screen and is updated automatically as you type your commands. XEmacs is advanced because it provides facilities beyond simple insertion and deletion, such as: automatic indentation of programs; viewing two or more files at once; and dealing in terms of characters, words, lines, sentences and regions. Self-documenting refers to the fact that at any time you can call up documentation of XEmacs from within XEmacs, simply by typing the character C-h (remember, that's ``Control-H'') twice. This will list the XEmacs commands you can use at present, and it also describes what each XEmacs command does.
The Sun Solaris environment runs version 21.1 of XEmacs.
Using XEmacs Elsewhere
Some of the commands described in this document may be unique to the local installation of XEmacs. If you have used XEmacs somewhere else, some of the commands may not work here; Similarly, some of the commands you learn here may not work elsewhere.
Characters, Keys and Commands
In XEmacs, you can enter any of the 128 ASCII characters into a file. This is usually done by typing the appropriate character on the keyboard. We will refer to certain special keys by the following notation:
Commands to XEmacs are entered by typing control and meta characters. A control character is entered by holding down the Control key at the same time a character is typed. For example, to enter the command indicated by ``Control-G,'' (command quit) hold down the Control key while typing g. It does not matter if you type a lower case or upper case g, it is interpreted the same by XEmacs. As a matter of convention, control characters are described as C-g, where g is the lower case letter.
A meta character is also entered by combining two keys. On any keyboard you can transmit a meta character by typing the Escape key, then typing the desired character. For example, type Escape and then an x to get the Meta-x character. Do not hold the Escape key down.
Again, following convention we will refer to a meta-character as M-l, where l is the lower case letter.
Control and meta characters are interpreted by XEmacs as commands
for it to perform some editing function on your file. Much of this
chapter describes what those commands do. Sometimes it is necessary
to insert a control character into a file. If you just type the
control character while you are typing text, XEmacs will try to
interpret it as a command. There is a special XEmacs command,
C-q, that lets you quote a control character. Entering C-q
C-l would put ^L (that's how ``control
L'' is displayed on the screen; C-l refers
specifically to typing ``control L'') into your file.
As with many of the XEmacs commands, the purpose of the command can
be used as a mnemonic device to help you remember the letter used to
enter the command (in this case, a ``q'', which can be
rememberd as ``quote'').
The control and meta commands we will be describing are really shortcuts for functions in XEmacs Lisp, which can also be entered directly with the M-x prefix. For example, C-q is bound to the function quoted-insert. You could get exactly the same behavior by typing M-x quoted-insert.
Getting Help
If you get into trouble while using XEmacs and do not know what to do or do not understand a message, you can always type C-g. This is the quit command and tells XEmacs to abandon whatever it is trying to do. XEmacs is an extremely powerful editor and has many more commands than will be discussed here. If you should accidentally type one of those commands, you may get prompted for more input. Just type C-g and continue. If a command you have executed has an effect you did not expect, you can use the undo command (C-x u) to reverse that effect.
XEmacs also has a built-in help facility. Typing C-h C-h shifts you into help mode. Typing C-g returns you to normal editing mode. Typing C-h only once followed by one of the help options takes you directly into that option. Some of the help options are described in table 6.1.
Table 6.1: XEmacs Help Options| Key | Mnemonic | Description |
|---|---|---|
| a | Command Apropos | Enter a substring of a command name, and see a list of commands that contain that substring. |
| b | Describe Key Bindings | Displays a list of all the shortcuts for XEmacs commands. |
| c | Describe Key Briefly | Enter a command shortcut, and see the name of the command. |
| k | Describe Key | Enter a command shortcut, and see the full documentation for that command. |
| t | Help With Tutorial | Starts an XEmacs tutorial session. |
| w | Where Is... | Enter an XEmacs command, and see the command shortcut (if any). |
If you want to perform some function, but do not know the XEmacs command, use the apropos command: type C-h a, followed by a keyword that describes the function you are trying to perform. For example, say you need to convert some upper case text to lower case. The command C-h a case will create a help window and display all commands with the word ``case'' in their descriptions.
There is an on-line tutorial in XEmacs that you may use by typing C-h t. This brings up a special tutorial file that you can edit to get some practice using the basic XEmacs commands.
XEmacs Menus
The current version of XEmacs has a menu bar at the top of its window so that you can access many of the most common XEmacs commands from menus. Clicking and holding on one of the words in the menu bar brings up the menu for commands in that topic. To execute a command from the menu, pull down the menu and drag the mouse cursor until the cursor is on top of the command. A box should form around the command if it is accessable at that time. When the box appears, release the mouse button. Where commands are available, they are listed in the menu. Using the menu system can be a quick way to find out the shortcut for a command. The table below describes the type of commands found on each menu.

Table 6.2: Basic XEmacs Menus
| Menu Panel | Commands |
|---|---|
| File | Options related to files and buffers. |
| Edit | Basic editing commands. |
| Apps | Applications that run inside of XEmacs. |
| Options | XEmacs configuration options. |
| Buffers | A list of active buffers. |
| Tools | Interfaces to various tools from XEmacs. |
| Packages | XEmacs Lisp packages, for editing modes, etc. |
Additional menus will be available at different times depending on the mode XEmacs is in. For example, when XEmacs is in the C language mode, a C menu will be available. (To see this, open a new file ending in .c, such as /tmp/foo.c.)
The Organization of the XEmacs Window
An XEmacs window is automatically created for you when you log in. XEmacs divides this window into several areas which contain their own sort of information. The biggest area is the one in which you usually see the text you are editing.
Text Windows and Buffers
While XEmacs is running in a single X window, it can split this window into several ``virtual windows.'' Initially there is one text window occupying all but the last line, which is the special echo area or minibuffer window in the last line. The text window can be subdivided into multiple text windows, each of which can be used for a different file.
The bottom line of each text window is the mode line, which
describes what is going on in that text window. It is in reverse
video and normally starts with the message -----XEmacs:
buffername. Its purpose is to indicate what buffer is being
edited. Each time you visit a file, a buffer is created to hold the
file's text. The name of the buffer is just the name of the
file.
The Mode Line
The mode line associated with each text window displays the following information:
- Modification Status
- When a file is first opened under XEmacs, the mode line will
start with five hyphens (
-----). This indicates that the file has not been modified. When a file is modified, this changes to--**-. If a file's permissions are set so that the file is read-only, the mode line will start with--%%-, since the file cannot be changed. - Buffer Name
- Next, the mode line displays
XEmacs: buffername. As noted above, this will normally be the file name. - XEmacs Modes
- The current major and minor XEmacs modes are displayed in parentheses on the right side of the mode line. XEmacs modes are discussed in section "Major Modes"
- Position
-
Finally, your position in the current file is displayed in the
line of hyphens on the left side of the mode line. Your position
will be one of the following:
- All
- If the entire file is visible.
- Top
- If the top lines of the file are visible.
- Bot
- If the bottom lines of the file are visible.
- XX%
- If only part of the file is visible, where XX is the percentage of the file which is above the top line displayed in the buffer.
The Echo Area
The line at the bottom of the XEmacs window is used to echo partial commands, and to display warning messages.
Echoing means printing the characters that you type. XEmacs never echoes single-character commands, and multi-character commands are echoed only if you pause while typing. As soon as you pause for more than a second in the middle of a command, all the characters of the command so far are echoed. This is intended to prompt you for the rest of the command. Once echoing has started, the rest of the command is echoed immediately when you type it. In this way, XEmacs can give confident users fast response and hesitant users maximum feedback.
If a command cannot be executed, it may print an error message in the echo area. Error messages may be accompanied by a beep. Any input you have typed that has not been displayed yet is thrown away when an error happens.
Some commands print informative messages in the echo area. These messages look like error messages but they do not beep and no input is thrown away. For example, the command C-x C-s saves the current file. Since the command does not affect the file being edited, you will not see any changes in the text window. Instead, a message indicating that the file has been saved is displayed in the echo area.
Certain commands require additional input from the user. For example, the command to visit another file to edit, C-x C-v, needs the path and the filename of the file you want to edit. When you enter C-x C-v, the words ``Find alternate file:'' and the pathname for the file you are editing show up in the echo area. When you type in the path and name of the file you want to edit, you are actually typing in a special text window called the minibuffer. The minibuffer always displays its contents in the echo area. When the minibuffer is in use, the echo area begins with a prompt string that usually ends with a colon. Also, the cursor appears in that line because it is the selected text window. You may use other XEmacs editing commands while in the minibuffer (for instance, to move the point). You can always get out of the minibuffer by typing C-g.
At some point, you may switch out of the minibuffer while in the middle of a command (for example, you might want to move the text cursor). When this happens, the echo line will display the partial command whenever it is not displaying something else. You can get back to this interrupted command by typing C-x o. At that point, you can either continue with the command, or abort it with a C-g.
Point, Mark and Region
When you move the mouse arrow into the XEmacs window, the terminal's cursor shows the location at which editing commands will take effect. This location is called the point. Other commands move the point through the text, so that you can edit at different places in it.
While the cursor appears to point at a character, the point should be thought of as between two characters. It points before the character that the cursor appears on top of. Sometimes we speak of the cursor when we mean the point, or speak of commands that move the point as cursor motion commands.
A related XEmacs concept is the mark. There are many XEmacs commands that operate on an arbitrary part of the current buffer. To specify the text on which a command should operate, set the mark at one end and the point at the other. The text between the point and the mark is called the region.
To select a region, click and hold the right mouse button on the character that starts the region, and move the mouse to the last character in the region. The region should be highlighted until you release the mouse button. Occasionally, you might find that the region does not quite match what you selected. Normally, this results from moving the mouse slightly just before releasing the mouse button. Try selecting the region again.
You can also select a region by moving the text cursor to one end of the region, typing C-@, and moving the text cursor to the other end of the region. C-@ sets the mark to be where the point is when the command is issued. If your region does not fit into your XEmacs window, you will need to use this method to select it.
Entering and Exiting XEmacs
You can quit XEmacs altogether by using the C-x C-c keystrokes. You'll be asked you if you want to save any changes to the file you were editing if you forgot to save it first. You will not normally want to get out of XEmacs altogether until you are ready to logout.
Editing Files With XEmacs
You can use XEmacs both to edit existing files or to create new ones. XEmacs automatically helps you avoid losing old information by saving the previous version of a file when you start to edit it.
Editing a New File
To create a new file with XEmacs, enter the XEmacs screen and type C-x C-v to visit the file. If you are already editing a file, then save the changes to that file before trying to create the new one. In the echo area you will be prompted for the file name. Note that a partial pathname may be displayed. If this is the pathname you want, complete the pathname by typing the name of the file you want to create. If the partial pathname is not what you desire, use the Backspace key to make corrections. XEmacs cursor control commands may be used to edit the pathname until it is correct. XEmacs looks for the file you have specified. Since it is a new file, the name does not exist and XEmacs will display a ``New File'' message in the echo area and display an empty buffer in the text window.
The point should be at the upper left corner of the text window. You can now enter text into the file simply by typing it. To save the file, type C-x C-s.
Editing an Existing File
To edit an existing file, again type C-x C-v (after saving any changes made to whatever file you might already be editing). As before, XEmacs will prompt you in the minibuffer with a partial pathname which you may either complete or correct. XEmacs will look for the file, and read it into the buffer. You can now begin editing the file.
If you incorrectly type the filename, you either will get the wrong file, or you will get an empty buffer since XEmacs will assume it is a file you want to create. In either case, just re-enter C-x C-v with the correct file name.
Again, after you finish editing, save the file with C-x C-s. This will save it with its original name. Sometimes you do not want to save the file with its original name. For example, if you have made extensive changes to a file, you might want to save the changed version under another name, and keep the old version under its old name. Do this with C-x C-w (think ``write file''). XEmacs will prompt you for a file name, save the changed file under that name, and make that new file available for editing in your XEmacs window.
Backup Files
Assume that you have been editing a file named sample.file. If you were to move back over to an xterm window and display sample.file, it would look like it did the last time you saved it in your XEmacs window. You might also notice that a sample.file~ is now in your directory. This is a backup file created automatically by XEmacs before any of your changes were made. This is a file you can go back to if something should happen to sample.file, or if you made a large number of unintended changes and would like to start over.
Occasionally, you may see a file #sample.file# in your
directory. This is an auto-save file created by XEmacs. Once you have
saved your file, the auto-save file is no longer needed and will be
discarded. If you have exited XEmacs without saving the changes to a
file, the auto-save file, if one was made, will stay in your
directory. This can be very helpful if, for instance, your client
loses power before you save a file. When you see an auto-save file in
your directory, check it to make sure that it is not more current
than the file itself. If the file is up-to-date, you can safely
remove the auto-save file. XEmacs will notice if you have an
auto-save file, and will suggest that you use the M-x
recover-file command to get it back. Again, if the file is
more current than the auto-save file, just get rid of the auto-save
file. Otherwise, use the mv command or XEmacs' M-x
recover-file command to replace the out-of-date file with the
auto-save file.
Moving Around the File
XEmacs has commands that move the cursor one character in any direction. These commands are mnemonic, that is the letter of the command reminds you of the function it performs. Note that all these commands merely move the cursor without affecting the text. The keys are:
- C-b
- Back one space.
- C-f
- Forward one space.
- C-n
- Next line.
- C-p
- Previous line.
XEmacs also understands the concept of words, sentences and lines. The keys to move the cursor in these larger units are:
- M-f
- Forward one word.
- M-b
- Backward one word.
- M-e
- Go to the end of the current sentence.
- M-a
- Go to the beginning of the current sentence.
- C-e
- Go to the end of the current line.
- C-a
- Go to the beginning of the current line.
There are several keys to move the cursor by large amounts. For example, to scroll forward or backward within the window:
- C-v
- Scroll forward one screen.
- M-v
- Scroll backward one screen.
If you know the position of the line you want to go to, you can go there using the following keys:
- M-g
- Goto line...
- M-<
- Go to the beginning of a file.
- M->
- Go to the end of the file.
Finally, clicking the mouse anywhere in the text window moves the cursor to that location.
Deleting Things
There are two ways to delete a single character: Delete deletes the character before the point; C-d deletes the character after the point. Recall that the point is actually between two characters, although on the screen the cursor looks like it is on top of a character. The Delete key has the effect of deleting the character before the cursor. The C-d key deletes the character on which the cursor sits.
You can also delete or kill text in the larger units of words, sentences and lines with the following keys:
- M-Delete
- Kills the word before the point.
- M-d
- Kills the word after the point.
- C-k
- Kills the rest of the line.
- M-k
- Kills the rest of the sentence.
Note that to kill an entire line you must be sure the point is at the beginning of the line. Use C-a C-k.
Note also that when text is killed in units larger than a character it is saved by XEmacs in the kill-ring. The contents of the kill-ring can be retrieved later by other commands. This protects you when you unintentionally delete text. To yank text back from the kill-ring use C-y to yank the last thing killed; and M-y to yank earlier kills.
Deleting Large Amounts of Text
The easiest way of deleting large amounts of text is to define the text to be deleted as a region. You can create a region either by setting the mark and the point, or by selecting it with the mouse. Next, use the wipe region command, C-w, to make the region disappear. Recall that it is really put in the kill-ring and can be retrieved with a C-y if you decide that you really did not want to delete it.
Adding Text
The simplest way of adding text to a file is to move the mouse cursor where you want the new text, click the mouse button, and begin typing. Note that the new text is actually entered before the current position of the point.
When you want to insert a new line of text before an existing line, you can do it by positioning the point at the beginning of the old line and typing the new line of text, followed by Return. However, it may be easier to see what you are doing if you first make a blank line and then insert the desired text into it. This is easy to do by using the open line command, C-o. This command inserts a new line after the point, leaving the point in form of the new line. You can now just type in the text for the new line.
The XEmacs window you will be using assumes that lines are 80 characters long. If you type too many characters on a line, all characters are entered in the file as one line, but are displayed across the text window on two or more eighty character lines. You can tell that this has happened if a line ends with a backslash ( \ ). This signifies that the following line is actually a continuation of the line above it. Since statements in the programming languages you are using may be entered on more than one line, you should avoid creating lines greater than 80 characters long.
If you would like to insert text from another file, type C-x i. You will be prompted for a filename. That file will be inserted at the point.
Undoing Changes
XEmacs allows all changes made in the text of a buffer to be undone, up to a certain amount of changed characters (8000 characters). The command to undo a change is C-x u. The first time you give this command, it undoes the last change. The point moves to the text affected by the undo, so you can see what was undone.
Consecutive repetitions of the C-x u command undo earlier and earlier changes, back to the limit of what XEmacs has recorded. If all recorded changes have been undone, the undo command prints an error message and does nothing. Any command other than an undo command breaks the sequence of undo commands. Starting at this moment, the previous undo commands are considered ordinary changes that can themselves be undone.
Repeating Commands
To execute a command more than once, you can invoke the command with a prefix. To prefix a command, type C-u, the value of the prefix, and then the command. There is a shortcut for numeric prefixes: M-5 to use a prefix of ``5'', M-4 for ``4'', etc. For example, the key to move to the next line is C-n. If you want to issue one command so that it will be run five times, you can do it by typing C-u 5 C-n or M-5 C-n.
Searching
Like other editors, XEmacs has commands that search for occurrences of a string. The principle search command is unusual in that it is incremental. When you type the first character of your search string, XEmacs will find that letter. XEmacs updates its search with each new letter you type. there are also non-incremental search commands more like those of other editors. The XEmacs search commands are:
- C-s string
- Searches for string.
- C-r string
- Searches backwards for string.
- C-s
- An incremental search forward.
- C-r
- An incremental search backward.
The first two commands are for non-incremental searches. Each command begins at the point and searches for the first occurrence of the given string, either forward or backward. If that string does not exist in the file, an error message is displayed and the point is not moved. If the word is found, the point is moved. It goes to the character after the word in a forward search, and the first character of the word in a backward search.
The last two commands begin incremental searches. For example, to do a forward incremental search, type C-s. Now start typing the string for which you want to search. As soon as you enter a character, XEmacs will move the point to the next occurrence of the partial string you have entered. If it is not the string you seek, continue to enter more characters. If you make a mistake in entering a character, use Backspace to cancel the last character in the string. When you find the string you want, you can exit the search by typing C-c. If you have found the first occurrence of the string you were looking for, but want to find another one, type another C-s instead of C-c. This second C-s tells XEmacs to search again. If you have already exited the search you can repeat it without re-typing the string by entering C-s C-s. The first C-s invokes the incremental search, the second C-s means search again with the last search string. If your search has failed and you try to repeat it with another C-s, it starts over again from the beginning of the buffer.
The C-g key does special things during searches. What it does depends on the status of the search. If the search has found what you have specified and is waiting for input, C-g cancels the entire search. The cursor moves back to where you started the search. If a C-g is typed when there are characters in the search string that have not been found, those characters are discarded. With them gone, the search is now successful and waiting for more input. A second C-g will now cancel the entire search.
Note that C-r starts an incremental search backwards from the point. It works in a manner analogous to C-s.
Replacing Text
There are two types of global search-and-replace commands in XEmacs. The first is an unconditional replacement command. That is, all occurrences of some old string will be replaced by a specified new string. Replacement always begins at the point and goes forward. the second type of global replace is called query-replace. In this command, XEmacs searches for the string you want to replace, positions the point to the next occurrence of that string, and waits for you to tell it to replace it or not. It then continues this search and query pattern. The format of these commands is:
M-& oldstring Return newstring Return M-% oldstring Return newstring Return
The first command above is the unconditional replacement command. XEmacs takes everything you type until the next Return as the oldstring for which it will searcha. Every thing you type before the last Return is taken as the new string.
The second command is the query replacement command. Entering the search and replace string is the same as the unconditional replacement command. XEmacs will pause at the next occurrence of the oldstring and wait for you to type in something that tells it what to do. The available commands are shown below.
- Space, y
- To replace oldstring with newstring.
- Delete, n
- To skip to the next occurrence without replacing this one.
- Escape
- To exit without any more replacements.
- . (Period)
- To replace this occurrence and then exit.
- ยท^
- To go back to the location of the previous occurrence if you changed it.
- !
- To replace all remaining occurrences without asking again.
You will get the message `Done'' when all occurrences have been queried.
Moving Text
In XEmacs, text is moved (cut and pasted) by killing it, moving the cursor to the new position, and yanking the killed text. Kill the text to be moved using one of the kill commands mentioned earlier: M-d (kill word), C-k (kill rest of line), M-k (kill rest of sentence), or C-w (wipe region). Then move the point to the place in the file where you want to insert the killed text, and type C-y (yank last kill).
Copying Text
Copying text is done in a manner analogous to moving text that has been defined as a region. First define the text to be copied as a region by setting the mark and the point. Then type M-w to save the region as the last killed, without actually killing it (copy-region-as-kill). You can now position the cursor to the desired place and type C-y to yank the copied text into the new place.
You can also copy text using the ``kill text'' commands described in the previous section. Simply kill the text you want to copy, yank it back in the same position with C-y, move the point to the place where you want the copy to go, and yank the text back again.
Changing Case
There are several commands that allow you to change words and regions from upper to lower case, lower to upper case, or to capitalize words (first letter upper case, the rest lower).
- M-l
- Convert following word to lower case.
- M-u
- Convert following word to upper case.
- M-c
- Capitalize the following word.
- C-x C-l
- Convert region to lower case.
- C-x C-u
- Convert region to upper case.
The first three commands only change the portion of the current word that comes after the point. The last two commands only change the text within the region.
Checking Your Spelling
The command M-x ispell-buffer will check for misspelled words in your current file. The spell-checking program will list the commands you can use in the minibuffer. When it finds a word it does not recognize, it looks for words that meet one of the following criteria:
- Words that match the unrecognized word if you remove one letter. For example, ``gin'' or ``gig'' for ``ging.''
- Words that match the unrecognized word if you change one letter. For example, ``wing'' or ``gong'' for ``ging.''
- Words that match the unrecognized word if you add one letter. For example, ``going'' or ``aging'' for ``ging.''
The words suggested by ispell are listed in a special minibuffer at the top of your XEmacs window. Each word is paired with a character. Entering that character changes the unrecognized word to the one ispell suggested. The spell-checker also allows the special commands listed in table 6.3.
Table 6.3: ispell Options| Command | Description |
|---|---|
| a | Add the current word to your personal dictionary. |
| r | Replace this word with another. The incorrectly spelled word is copied to the minibuffer, so you can edit it. |
| Space | Skip this word. Do not change the word here, but do not ignore it if it appears later in this XEmacs session. |
| ? | Minimal help on using the spelling checker. |
| C-g | Quit ispell. |
Multiple Windows
You can have several different files open for editing in a single XEmacs session at the same time. When you open a file using the visit file command (C-x C-v), the file you open replaces whatever file might already be using the current buffer. However, there is an alternate command to open a file called the find file command (C-x C-f). When you open a file with this command, XEmacs creates a new buffer for the new file, while retaining the current file in its buffer. If you only have two buffers, you can move from one to the other with the C-x b key combination. If you have more than two buffers, you can access any buffer by bringing up a buffer menu. Click and hold the left mouse button on your XEmacs window. A list of available buffers will appear on your screen, with the current buffer directly under the mouse cursor, and highlighted with a rectangle. To select another buffer, move the mouse cursor so that the other buffer's name is highlighted, and release the mouse button.
It is possible to split the text window into two (or more) text windows. Each of these text windows may be displaying a different buffer (file). Note that each of the text windows will have its' own mode line, but that the echo area is shared by all the text windows. You can use multiple text windows to edit two (or more) files at the same time.
The XEmacs window commands are:
- C-x 2
- Split the current text window into two text windows.
- C-x 0
- Get rid of the current text window.
- C-x 1
- Get rid of all the windows except the current one.
The last command is the most important for you to know, since using multiple text windows is not recommended. However, it is possible that you will accidently create multiple windows. To get rid of them, first move the mouse arrow to the text window you want. Click the mouse to move the cursor into that window, making it the current text window, and then type C-x 1 to remove all the other text windows.
In general, we recommend that you use one text window, and one buffer; this forces you to save changes to one file before editing another.
Major Modes
XEmacs has many different major modes, each of which customizes XEmacs for editing text of a particular sort. XEmacs determines which mode to use based on the file name. In general, an extension to the file name determines what mode will be used when you edit that file. Table 6.4 has a list of some of XEmacs' major modes and the filename extensions that activate them.
Table 6.4: XEmacs Automatic Major Mode Selection| Filename Extension | Mode |
|---|---|
| .c, .h, .y | C |
| .cc, .C, .c++ | C++ |
| .m | Objective C |
| .el | Emacs Lisp |
| .f | Fortran |
| .l, .lisp, .lsp, .ml, .cl | Lisp |
| .mod, .m2, .def | Modula-2 |
| .[1-8], .man, .me, .mm, .mr, .ms | nroff |
| .pas, .p | Pascal |
| .prolog | Prolog |
| .pl, .pm | Perl |
| .py | Python |
| .scm | Scheme |
| .tex, .TeX | TEX, LATEX |
| .sty, .bbl | LATEX |
| .texinfo, .texi | TEXinfo |
| .bib | BibTEX |
| .text, .article, .letter | Text |
TEX, LATEX, and nroff are document typesetting systems. Text mode is for editing ordinary text files. The other modes are for various programming languages.
Many of the modes available have special, mode-specific commands. The command M-x describe-mode lists the special commands available for your current mode.
If XEmacs does not know of a special mode for a particular file, that file will be opened in Fundamental mode. Fundamental mode makes no assumptions as to how a file should be formatted, and provides none of the special commands available in the other modes.