Text Editors
Even though you might think that you'll never have a reason to use anything other than a GUI text editor such as Pepper or BBEdit, there are a few arguments to be made for text-only mode editing in a terminal. Among them are that the text-only editors can even be used when the system can't display a GUI interface, and that an editor in a terminal can start much faster than most GUI editors. There's also the advantage that if you have occasion to work on Unix machines other than OS X boxes, the command-line editors are what you will have available.
Finally, at this point, the GUI clients available currently seem to have a bit of a problem figuring out whether they should convert a file that they load into Mac-style text (for newlines), or Unix-style text. The Unix command-line editors are a bit more predictable in preferring Unix-format text.
When it comes to editing text on the Unix side, you'll find that many Unix programs use text files as input, create text files as output, or are configured using commands and variables set up in text files. To change the contents of these files, you'll need to make use of a text editor.
As a matter of fact, most Unix software doesn't know the difference between a text file and any other file. Unlike in Mac OS, from the OS X operating system's point of view, files are files are files. If the user chooses to view some of them as containing text, and some as containing programs, that's the user's business. An interesting consequence of this lack of concern about a file's contents is that the operating system is just as happy to allow you to use a text editor to edit the contents of your spreadsheet program as it is to enable you to attempt to run your e-mail. Of course, if you actually have execute permission turned on for your e-mail and try to run it, it's almost certainly going to result in nothing more interesting than a Bus Error and an immediate exit of the command—but the OS will try.
If you spend much time discussing Unix editors with longtime Unix users, you'll find that there is a disagreement of warlike proportions between the users of the two most common editors: vi and emacs. Although these editors are actually rather complementary in their functions and are both useful tools to have in your toolbox, chances are that you will run into many users who insist that one or the other editor is completely useless. If you listen to them, you'll be depriving yourself of the better solution to at least some tasks.
Many Unix editors have immense power. emacs, for example, not only contains its own built-in programming language, but can also function as a complete windowing system, a compiler/debugger interface, a news reader, and many other things. Even with a book of this size, however, there isn't space to do more than address the basics of using these editors. After you've mastered the basics, if you're interested in learning more, we encourage you to stop by your local bookstore or library and choose from among the several books available on each of the major Unix editors.
Quick, Dirty, and Omnipresent: vi
The vi editor is Unix's most universal editor. Some users pronounce it vee-eye, and some pronounce it vye, and a growing contingent who claim it's pronounced six, when used on OS-X. There seems to be no concrete consensus which pronunciation is correct (but the people who say vye are still wrong). vi isn't an easy editor, and it isn't friendly.
It is, however, a quick-starting editor with a small memory footprint, which you will find on every Unix machine you encounter, regardless of flavor. vi, although annoying to learn, is frequently the most convenient editor to use for doing things like making single-line changes to configuration files.
When you start vi, there are a number of things you need to know to make it useful. The Return key has been included in the explanations here because some commands take effect immediately, and some require you to press Return after you enter them.
vi operates in one of two modes: command mode or insert mode. In command mode, you have control over things such as cursor position, deleting characters, and saving files. In command mode, every keyboard character you type will be interpreted as part of a command of some sort. In insert mode, every keyboard key you type is inserted into the file you are editing. This distinction is bound to be confusing at first, but if you use vi, you'll find that its speed makes it a preferred editor for quick changes to files.
Some of the most used keys and tasks are shown in Table 15.7.
Table 15.7. Common Key Presses and the Resultant Actions in vi
| Mode
|
Key(s)/Key Combination(s)
|
Action
|
| Command
|
l
|
Move right
|
| |
h
|
Move left
|
| |
j
|
Move to next line
|
| |
k
|
Move to previous line
|
| |
Put cursor on character and press x key
|
Delete character under cursor
|
| |
Press d key twice
|
Delete an entire line, including an empty line
|
| |
A
|
Enter insert mode at end of current line
|
| |
i
|
Enter insert mode before the character under the cursor
|
| |
a
|
Enter insert mode after the character under the cursor
|
| |
:w Return
|
Save the file
|
| |
:w <filename> Return
|
Save the file to <fil
e
name>
|
| |
:q Return
|
Quit
|
| |
:q! Return
|
Quit without saving
|
| |
:wq!
|
Save file and exit
|
| Insert Mode
|
Esc key
|
Switch to command mode
|
| |
Backspace or Delete key
|
Backspaces or deletes, but only for data entered in current insert mode session on the current line
|
| |
Any printable keyboard
|
Insert the character at the cursor character
|
Instead of trying to walk through a screenshot by screenshot example of using vi, try typing the following example. Remember to compare what you're typing to the commands in the previous table, and watch what happens. Although the finer details are not revealed by this example, you will pick up enough to get you started doing useful work, and to get you out of any sticky situations you might get yourself into while editing a file.
Try typing the following exactly as it appears here, and observe what happens. Where a new line appears in the text, press Return. Remember that <esc> is the Escape key.
% vi mynewfile
iThis is my new file
This is line one of my new file
This is a test
This is line four of my new file<esc>kddkA
This is line three of my new file<esc>khhhhhhhhhhhhhhhhhxxxitwo<esc>:wq!
Your machine should respond
"mynewfile" [New file] 4 lines, 119 characters
Now look at what you've got:
% cat mynewfile
This is my new file
This is line two of my new file
This is line three of my new file
This is line four of my new file
Table 15.8 shows the command documentation table for the vi command.
Table 15.8. The Command Documentation Table for vi
|
vi
|
|
ex
|
|
view
|
Screen-oriented text editor
|
| Line-oriented screen editor
|
| Read-only version of vi
|
vi [-eFlRrSv] [-c <cmd>] [-t <tag>] [-w <size>] [<file1>
<file2> ...]
ex [-eFlRrSsv] [-c <cmd>] [-t <tag>] [-w <size>] [<file1>
<file2> ...]
view [-eFlRrSv] [-c <cmd>] [-t <tag>] [-w <size>] [<file1>
<file2> ...]
|
|
vi is a screen-oriented text editor; ex is a line-oriented editor. vi and ex are different interfaces to the same program. view is equivalent to vi -R, the read-only option to vi.
|
| The following options are available:
|
|
-e
|
Starts to edit in ex mode.
|
|
-F
|
Doesn't copy the entire file when first starting to edit. Default is to make a copy in case someone else modifies the file during your edit session.
|
|
-l
|
Starts editing with the lisp and showmatch options set.
|
|
-R
|
Starts editing in read-only mode.
|
|
-r
|
Recovers the specified file. If no file is specified, it lists the files that could be recovered. If no recoverable files with the specified name exists, vi starts editing as if the option has not been issued.
|
|
-S
|
Runs with secure edit option set, which disallows all access to external programs.
|
|
-s
|
Enters batch mode. Applicable only to ex. It is useful for running ex scripts.
|
|
-v
|
Starts editing in vi mode.
|
|
-c
<cmd>
|
Executes <cmd> immediately after starting the edit session. It is especially useful for initial positioning in the file, but is not limited to positioning commands.
|
|
-t
<tag>
|
Starts editing at the specified <tag>.
|
|
-w
<size>
|
Sets the initial window size to
<size>
lines.
|
| vi has two modes: command mode and input mode. Command mode is the initial and normal mode. Completion of the input mode returns the user to command mode. Pressing the Esc key ends a partial command.
|
| Input mode is required to input some types of edits. Input mode is terminated by pressing the Esc key. Upon termination of input mode, the user is returned to command mode.
|
| Some commands for moving around in a file:
|
|
h
|
Moves the cursor one character to the left.
|
|
l
|
Moves the cursor one character to the right.
|
|
j
|
Moves the cursor one line down.
|
|
k
|
Moves the cursor one line up.
|
|
<arrow keys>
|
The arrow keys often also function properly.
|
|
<num>
G
|
Moves the cursor to the line number specified by
<num>
. If
<num
> is not specified, the cursor moves to the last line of the file.
|
| Some commands for inputting text (input mode):
|
|
i
|
Inserts text before the cursor.
|
|
a
|
Appends new text after the cursor.
|
|
A
|
Appends new text at the end of the line where the cursor is.
|
|
o
|
Opens a new line below the line where the cursor is and allows the user to start entering text on the new line.
|
|
O
|
Opens a new line above the line where the cursor is, and allows the user to start entering text on that new line.
|
| Some commands for copying text:
|
|
yy
|
Copies the line the cursor is on.
|
|
p
|
Appends the copied line after the line the cursor is on.
|
| Some commands for deleting text:
|
|
dd
|
Deletes the line the cursor is on.
|
|
<num>
dd
|
Deletes <num> lines, starting with the line the cursor is on.
|
|
dw
|
Deletes the word the cursor is on.
|
|
x
|
Deletes the character the cursor is on.
|
| Some other useful text manipulation:
|
|
r
<x>
|
Replaces the character the cursor is on with <x>.
|
|
J
|
Joins the line the cursor is on with the line below.
|
| Some commands for pattern searching:
|
|
/
<pattern>
|
Searches forward in the file for <pattern>, starting with the location of the cursor.
|
|
?
<pattern>
|
Searches backward in the file for <pattern>, starting with the location of the cursor.
|
|
n
|
Repeats the last / or ? pattern search.
|
|
N
|
Repeats the last / or ? pattern search in reverse.
|
| Some commands to write the file:
|
|
:w<return>
|
Writes the file back to the filename originally specified when vi was started.
|
|
:w
<filename
><return>
|
Writes the file to the filename specified by <filename>.
|
| Some commands to quit editing and exit vi:
|
|
:q<return>
|
Exits vi. Refuses to quit if there are any unsaved modifications, or if the file is read-only.
|
|
:q!
|
Exits vi, even if there are any unsaved modifications.
|
|
ZZ
|
Exits vi, saving changes.
|
Everything and the Kitchen Sink: emacs
On the other end of the spectrum from vi's odd syntax and tiny footprint is emacs. In certain circles, it is thought that emacs is an acronym for Emacs Makes a Computer Slow because emacs epitomizes the notion of an everything package, and has the memory footprint to prove it. Including a windowing system, an e-mail reading client, a news reading client, a programming language, and an online help database, to name only a few of its features, emacs can almost certainly do anything you want a plain text editor to do.
With today's fast machines and nearly unlimited memory, the major complaints against emacs aren't a significant impediment to its use.
From the point of view of the average user, emacs has a much more intuitive interface than vi. You're always in insert mode, just like you're used to in GUI-based word processors. Commands are handled by the use of Control+<key> combinations, instead of the use of a separate mode.
To use emacs, there are some basics that you need to know—you can get more information from the online tutorial mentioned at the end of this section. In the following list, whenever you see Ctrl+ preceding a character, it means that you need to hold down the Control key and type that character. Whenever you see Esc- preceding a character, it means to press the Esc key, and then the character.
- The emacs editor doesn't have a separate mode for entering commands. You are always either typing a command or typing text—no switching between modes for them. This is just like most word processors that you are probably familiar with. To enter text, just type what you want to appear. To enter a command (usually Ctrl+<key> or Esc-x <somecommand>), just type the command as shown.
- You can position the cursor keys in emacs by using the arrow keys. If you're working across a network connection, the arrow keys might not work, but you can also position the cursor with Ctrl+<key> combinations. Ctrl+f moves the cursor forward. Ctrl+b moves it back. Ctrl+n moves to the next line. Ctrl+p moves up one line.
- You can delete everything from the cursor to the end of the line with Ctrl+k. A second Ctrl+k will delete the now blank line.
- Ctrl+g is the emacs "quit what you're doing" command. If you've started typing a command and change your mind, press Ctrl+g to abort.
- If you use Ctrl+k to delete a line or lines, you can use Ctrl+y to yank it (them) back. You don't have to yank them to the same location from which you deleted them.
- To save the file you're working on, press Ctrl+x Ctrl+s.
- To save the file to a new name, press Ctrl+x Ctrl+w <filename>Return.
- To exit emacs, press Ctrl+x Ctrl+c. If emacs proceeds to ask you about unsaved buffers, it's because you have unsaved work. You can either answer no, and save your work, or answer yes to the "quit anyway?" questions and exit without saving.
Beyond the Ctrl+ commands available in emacs, there's also an amazingly extensible set of commands that come into play if you use the Escape key. These commands are usually known as emacs meta commands, even though the machine with the meta key from which the commands draw their name has long since faded into history. These commands, even though they're initiated by pressing the Escape key, are usually abbreviated in the documentation with a leading M, for meta. The complete set of these commands is the subject of more than one book, and we recommend that you investigate your library or bookstore options, if you really want to understand the inner workings. If you're a puzzle solver, many of the interesting items are documented in Table 15.9. A good place to start on meta commands will be with testing out the emacs online help system. Start emacs by simply typing emacs at the prompt. After it starts, press Esc-x, and then type help- and press the spacebar. You will be presented with a list of emacs commands starting with help-, including useful things such as help-for-help, a very good place to start.
Instead of a quick example like we used for vi above, we suggest you take the emacs tutorial. To enter the emacs tutorial, all you need to do is start emacs, and type Ctrl+h i (hold the Ctrl key, press the h key, release them both, and press the i key). If you type a ? after the Ctrl+h instead of the i, you'll see that there is actually a whole world of alternatives to the i. These alternatives give you access to a range of different types of helpful information. For now, take the tutorial. If you're curious, you can probably spend a near eternity exploring the rest of the options available.
Table 15.9 shows the a portion of the command documentation table for emacs, as well as a listing of some of the help topics detailing a number of the available meta commands. The synopses of the help topic areas should give you an idea of some of the things that you can do, and some of the information that you can look for in the online documentation. This table is derived from the emacs internal documentation, and it can be accessed in emacs itself by typing M-x info, and selecting the emacs documentation line. It should be clear from this listing that the complete documentation for emacs is rather voluminous.
Table 15.9. The Command Documentation Table for emacs
|
emacs
|
Editor
|
|
emacs [
<command-line switches>
] [
<file1>
<file2>
...]
|
|
emacs is a powerful editor that can actually do more than edit files. It has an extensive information system, which can be accessed in emacs with the key sequence <Ctrl+h i> (holding the Control key and h and then i). The information system can be navigated using the arrow keys to move around and pressing the Enter key to make a selection.
|
|
emacs has an interactive help facility, <Ctrl+h>. The information facility is one of the types of help available. A help tutorial is available with <Ctrl+h t>. Help Apropos <Ctrl+h a> helps the user find a command given its functionality. Help Character <Ctrl+h c> describes a given character's effect.
|
| The following are emacs options of general interest:
|
|
<file>
|
Edits the specified
<file>
.
|
|
+
<number>
|
Moves the cursor to the line number specified by <number>. (Do not include a space between + and <number>.)
|
|
-q
|
Does not load an init file.
|
|
-u
<user>
|
Loads the init file of the specified
<user>
.
|
|
-t
<file>
|
Uses the specified
<file>
as the terminal instead of using stdin/stdout. This must be the first argument specified in the command line.
|
|
-nw
|
Tells emacs not to use its special X interface. If this option is given when invoking emacs in an xterm(1) window, the emacs display is done in that window. This must be the first option specified in the command line.
|
| The following are basic emacs key sequences. Remember that two keys pressed simultaneously have a plus sign between them, and a space indicates pressing them sequentially. Most Unix documentation, including the online man pages and info pages will document Esc-x as M-x, for the Meta key:
|
| Up Arrow
|
Move cursor up one line.
|
| Left Arrow
|
Move cursor to the left one character, to end of previous line if at left side of current line.
|
| Right Arrow
|
Move cursor to the right one character, move to the beginning of the next line if at the right side of the current line.
|
| Down Arrow
|
Move cursor down one line. Adds a new line to the file, if currently on the last line of the file.
|
| Ctrl+p
|
Move cursor up one line.
|
| Ctrl+b
|
Move cursor to the left one character, to end of previous line if at left side of current line.
|
| Ctrl+f
|
Move cursor to the right one character, move to the beginning of the next line if at the right side of the current line.
|
| Ctrl+n
|
Move cursor down one line. Adds a new line to the file, if currently on the last line of the file.
|
| Ctrl+v
|
Move down one page in file.
|
| Esc-v
|
Move up one page in file
|
| Ctrl+l
|
Move current line to the center of the page
|
| Ctrl+a
|
Move cursor to the beginning of the current line.
|
| Ctrl+e
|
Move cursor to the end of the current line.
|
| Esc-a
|
Move cursor to the beginning of the current sentence.
|
| Esc-e
|
Move cursor to the end of the current sentence.
|
| Ctrl+x Ctrl+h
|
Bring up list of Ctrl+x prefixed commands. (If you do this, you will see that this table is a very abbreviated list!)
|
| Ctrl+x Ctrl+s
|
Saves the file.
|
| Ctrl+x Ctrl+w
|
Prompt for new name to save file.
|
| Ctrl+x Ctrl+c
|
Exits emacs.
|
| Ctrl+x Ctrl+f
|
Prompt to open file.
|
| Ctrl+x Ctrl+b
|
List current file buffers.
|
| Ctrl+x b
|
Prompt to switch to another buffer.
|
| Esc-x find-file-literally
|
Prompt to open file in literal mode—no Mac/Unix linefeed interpretation and so on.
|
| Ctrl+x Ctrl+d
|
List directory in emacs buffer (allows opening files by browsing directory rather than by typing name).
|
| Ctrl+x Ctrl+o
|
Delete blank lines in file.
|
| Ctrl+x Ctrl+t
|
Transpose lines.
|
| Ctrl+spacebar
|
Set mark at the current cursor position.
|
| Ctrl+x Ctrl+l
|
Downcase region. The region is the area between the cursor, and where the current mark is set.
|
| Ctrl+x Ctrl+u
|
Upcase region. The region is the area between the cursor, and where the current Mark is set.
|
| Ctrl+w
|
Delete from mark to cursor. Deleted text goes to kill-ring buffer.
|
| Esc-w
|
Copy from mark to cursor into kill-ring buffer.
|
| Ctrl+k
|
Delete from cursor to end of line. Place deleted text in kill-ring buffer.
|
| Ctrl+y
|
Yank top data from kill-ring buffer into the text at the current cursor position.
|
| Ctrl+x 2
|
Split current window vertically into two editing windows (two full-width windows, half the previous height).
|
| Ctrl+x 3
|
Split current window horizontally into two editing windows (two full-height windows, half the previous width).
|
| Ctrl+x o
|
Switch to next editing window in split-window mode.
|
| Ctrl+x 1
|
Switch to single-window mode, keeping the current window open.
|
| Ctrl+x 0
|
Remove current editing window, keeping others.
|
| Ctrl+x (
|
Start recording keyboard macro.
|
| Ctrl+x )
|
Stop recording keyboard macro.
|
| Ctrl+x e
|
Execute recorded keyboard macro.
|
| Ctrl+u <####>
|
Creates a numeric argument for the next command.
|
| Ctrl+u <####> <keyseq>
|
Execute <keyseq> ##### times.
|
| Ctrl+x f
|
Set fill column for word wrap. Requires a numeric argument set with Ctrl+u <####>.
|
| Esc-x fill-region
|
Word wrap region between cursor and mark.
|
| Ctrl+h Ctrl+h
|
Bring up menu of help subjects.
|
| Ctrl+h t
|
Bring up emacs tutorial.
|
| Ctrl+h i
|
Bring up emacs info-mode manual browser. Browsing through the emacs info through this interface is recommended.
|
| Esc-x info
|
Bring up emacs info-mode manual browser.
|
| Esc-x apropos
|
Prompt for command or key sequence to document.
|
| Ctrl+h h
|
Bring up list of ways to say hello in 34 different languages—we told you emacs had everything in it!
|
|
The following is a listing of some of the interesting parts of the information system's main menu for emacs:
File: emacs, Node: Top, Next: Distrib, Prev: (dir), Up: (dir)
The Emacs Editor ****************
Emacs is the extensible, customizable, self-documenting real-time display editor. This Info file describes how to edit with Emacs and some of how to customize it; it corresponds to GNU Emacs version 20.3. For information on extending Emacs, see *Note Emacs Lisp: (elisp)Emacs Lisp.
* Menu:
* Distrib:: How to get the latest Emacs distribution. * Copying:: The GNU General Public License gives you permission to redistribute GNU Emacs on certain terms; it also explains that there is no warranty. * Intro:: An introduction to Emacs concepts. * Glossary:: The glossary. * Antinews:: Information about Emacs version 19. * MS-DOS:: Using Emacs on MS-DOS (otherwise known as "MS-DOG"). * Manifesto:: What's GNU? Gnu's Not Unix! * Acknowledgments:: Major contributors to GNU Emacs.
Indexes (nodes containing large menus) * Key Index:: An item for each standard Emacs key sequence. * Command Index:: An item for each command name. * Variable Index:: An item for each documented variable. * Concept Index:: An item for each concept.
Important General Concepts * Screen:: How to interpret what you see on the screen. * User Input:: Kinds of input events (characters, buttons, function keys). * Keys:: Key sequences: what you type to request one editing action. * Commands:: Named functions run by key sequences to do editing. * Text Characters:: Character set for text (the contents of buffers and strings). * Entering Emacs:: Starting Emacs from the shell. * Exiting:: Stopping or killing Emacs. * Command Arguments:: Hairy startup options.
Fundamental Editing Commands * Basic:: The most basic editing commands. * Minibuffer:: Entering arguments that are prompted for. * M-x:: Invoking commands by their names. * Help:: Commands for asking Emacs about its commands.
Important Text-Changing Commands * Mark:: The mark: how to delimit a "region" of text. * Killing:: Killing text. * Yanking:: Recovering killed text. Moving text. * Accumulating Text:: Other ways of copying text. * Rectangles:: Operating on the text inside a rectangle on the screen. * Registers:: Saving a text string or a location in the buffer. * Display:: Controlling what text is displayed. * Search:: Finding or replacing occurrences of a string. * Fixit:: Commands especially useful for fixing typos.
Major Structures of Emacs * Files:: All about handling files. * Buffers:: Multiple buffers; editing several files at once. * Windows:: Viewing two pieces of text at once.
* Postscript Variables:: Customizing the PostScript printing commands. * Sorting:: Sorting lines, paragraphs, or pages within Emacs. * Narrowing:: Restricting display and editing to a portion of the buffer. * Two-Column:: Splitting apart columns to edit them in side-by-side windows. * Editing Binary Files:: Using Hexl mode to edit binary files. * Saving Emacs Sessions:: Saving Emacs state from one session to the next. * Recursive Edit:: A command can allow you to do editing  "within the command". This is called a `recursive editing level'. * Emulation:: Emulating some other editors with Emacs. * Dissociated Press:: Dissociating text for fun. * Amusements:: Various games and hacks. * Customization:: Modifying the behavior of Emacs.
Recovery from Problems * Quitting:: Quitting and aborting. * Lossage:: What to do if Emacs is hung or malfunctioning.
* Bugs:: How and when to report a bug. * Contributing:: How to contribute improvements to Emacs. * Service:: How to get help for your own Emacs needs.
Here are some other nodes which are really inferiors of the ones already listed, mentioned here so you can get to them in one step:
— The Detailed Node Listing —
The Organization of the Screen
* Point:: The place in the text where editing commands operate. * Echo Area:: Short messages appear at the bottom of the screen. * Mode Line:: Interpreting the mode line. * Menu Bar:: How to use the menu bar.
Basic Editing Commands
* Inserting Text:: Inserting text by simply typing it. * Moving Point:: How to move the cursor to the place where you want to change something. * Erasing:: Deleting and killing text.
* Undo:: Undoing recent changes in the text. * Files: Basic Files. Visiting, creating, and saving files. * Help: Basic Help. Asking what a character does. * Blank Lines:: Commands to make or delete blank lines. * Continuation Lines:: Lines too wide for the screen. * Position Info:: What page, line, row, or column is point on? * Arguments:: Numeric arguments for repeating a command.
The Minibuffer
* Minibuffer File:: Entering file names with the minibuffer. * Minibuffer Edit:: How to edit in the minibuffer. * Completion:: An abbreviation facility for minibuffer input. * Minibuffer History:: Reusing recent minibuffer arguments. * Repetition:: Re-executing commands that used the minibuffer.
Help
* Help Summary:: Brief list of all Help commands. * Key Help:: Asking what a key does in Emacs. * Name Help:: Asking about a command, variable or function name. * Apropos:: Asking what pertains to a given topic.
* Library Keywords:: Finding Lisp libraries by keywords (topics). * Language Help:: Help relating to international language support. * Misc Help:: Other help commands.
The Mark and the Region
* Setting Mark:: Commands to set the mark. * Transient Mark:: How to make Emacs highlight the region when there is one. * Using Region:: Summary of ways to operate on contents of the region. * Marking Objects:: Commands to put region around textual units. * Mark Ring:: Previous mark positions saved so you can go back there. * Global Mark Ring:: Previous mark positions in various buffers.
Deletion and Killing
* Deletion:: Commands for deleting small amounts of text and blank areas. * Killing by Lines:: How to kill entire lines of text at one time. * Other Kill Commands:: Commands to kill large regions of text and syntactic units such as words and sentences.
Yanking
* Kill Ring:: Where killed text is stored. Basic yanking. * Appending Kills:: Several kills in a row all yank together. * Earlier Kills:: Yanking something killed some time ago.
Registers
* RegPos:: Saving positions in registers. * RegText:: Saving text in registers. * RegRect:: Saving rectangles in registers. * RegConfig:: Saving window configurations in registers. * RegFiles:: File names in registers. * Bookmarks:: Bookmarks are like registers, but persistent.
Controlling the Display
* Scrolling:: Moving text up and down in a window. * Horizontal Scrolling:: Moving text left and right in a window. * Follow Mode:: Follow mode lets two windows scroll as one. * Selective Display:: Hiding lines with lots of indentation.
* Optional Mode Line:: Optional mode line display features. * Text Display:: How text is normally displayed. * Display Vars:: Information on variables for customizing display.
Searching and Replacement
* Incremental Search:: Search happens as you type the string. * Nonincremental Search:: Specify entire string and then search. * Word Search:: Search for sequence of words. * Regexp Search:: Search for match for a regexp. * Regexps:: Syntax of regular expressions. * Search Case:: To ignore case while searching, or not. * Replace:: Search, and replace some or all matches. * Other Repeating Search:: Operating on all matches for some regexp.
Replacement Commands
* Unconditional Replace:: Replacing all matches for a string. * Regexp Replace:: Replacing all matches for a regexp. * Replacement and Case:: How replacements preserve case of letters. * Query Replace:: How to use querying.
Commands for Fixing Typos
* Kill Errors:: Commands to kill a batch of recently entered text. * Transpose:: Exchanging two characters, words, lines, lists... * Fixing Case:: Correcting case of last word entered. * Spelling:: Apply spelling checker to a word or a whole buffer.
File Handling
* File Names:: How to type and edit file-name arguments. * Visiting:: Visiting a file prepares Emacs to edit the file. * Saving:: Saving makes your changes permanent. * Reverting:: Reverting cancels all the changes not saved. * Auto Save:: Auto Save periodically protects against loss of data. * File Aliases:: Handling multiple names for one file. * Version Control:: Version control systems (RCS, CVS and SCCS). * Directories:: Creating, deleting, and listing file directories. * Comparing Files:: Finding where two files differ. * Misc File Ops:: Other things you can do on files. * Compressed Files:: Accessing compressed files. * Remote Files:: Accessing files on other sites. * Quoted File Names:: Quoting special characters in file names.
Saving Files
* Backup:: How Emacs saves the old version of your file. * Interlocking:: How Emacs protects against simultaneous editing of one file by two users.
Version Control
* Introduction to VC:: How version control works in general. * VC Mode Line:: How the mode line shows version control status. * Basic VC Editing:: How to edit a file under version control. * Old Versions:: Examining and comparing old versions. * Secondary VC Commands:: The commands used a little less frequently. * Branches:: Multiple lines of development. * Snapshots:: Sets of file versions treated as a unit. * Miscellaneous VC:: Various other commands and features of VC. * Customizing VC:: Variables that change VC's behavior.
Using Multiple Buffers
* Select Buffer:: Creating a new buffer or reselecting an old one.
* List Buffers:: Getting a list of buffers that exist. * Misc Buffer:: Renaming; changing read-onlyness; copying text. * Kill Buffer:: Killing buffers you no longer need. * Several Buffers:: How to go through the list of all buffers and operate variously on several of them. * Indirect Buffers:: An indirect buffer shares the text of another buffer.
Multiple Windows
* Basic Window:: Introduction to Emacs windows. * Split Window:: New windows are made by splitting existing windows. * Other Window:: Moving to another window or doing something to it. * Pop Up Window:: Finding a file or buffer in another window. * Force Same Window:: Forcing certain buffers to appear in the selected window rather than in another window. * Change Window:: Deleting windows and changing their sizes.
Frames and X Windows
* Mouse Commands:: Moving, cutting, and pasting, with the mouse. * Secondary Selection:: Cutting without altering point and mark. * Mouse References:: Using the mouse to select an item from a list.
* Menu Mouse Clicks:: Mouse clicks that bring up menus. * Mode Line Mouse:: Mouse clicks on the mode line. * Creating Frames:: Creating additional Emacs frames with various contents. * Multiple Displays:: How one Emacs job can talk to several displays. *Special Buffer Frames:: You can make certain buffers have their own frames. * Frame Parameters:: Changing the colors and other modes of frames. * Scroll Bars:: How to enable and disable scroll bars; how to use them. * Menu Bars:: Enabling and disabling the menu bar. * Faces:: How to change the display style using faces. * Font Lock:: Minor mode for syntactic highlighting using faces. * Support Modes:: Font Lock support modes make Font Lock faster. * Misc X:: Iconifying and deleting frames. Region highlighting. Non-Window Terminals:: Multiple frames on terminals that show only one.
Font Lock Support Modes
* Fast Lock Mode:: Saving font information in files. * Lazy Lock Mode:: Fontifying only text that is actually displayed. * Fast or Lazy:: Which support mode is best for you?
International Character Set Support
* International Intro:: Basic concepts of multibyte characters. * Enabling Multibyte:: Controlling whether to use multibyte characters. * Language Environments:: Setting things up for the language you use. * Input Methods:: Entering text characters not on your keyboard. * Select Input Method:: Specifying your choice of input methods. * Coding Systems:: Character set conversion when you read and write files, and so on. * Recognize Coding:: How Emacs figures out which conversion to use. * Specify Coding:: Various ways to choose which conversion to use. * Fontsets:: Fontsets are collections of fonts that cover the whole spectrum of charac- ters. * Defining Fontsets:: Defining a new fontset. * Single-Byte European Support:: You can pick one European character set to use without multibyte characters.
Major Modes
* Choosing Modes:: How major modes are specified or chosen.
Indentation
* Indentation Commands:: Various commands and techniques for indentation. * Tab Stops:: You can set arbitrary "tab stops" and then indent to the next tab stop when you want to. * Just Spaces:: You can request indentation using just spaces.
Commands for Human Languages
* Words:: Moving over and killing words. * Sentences:: Moving over and killing sentences. * Paragraphs:: Moving over paragraphs. * Pages:: Moving over pages. * Filling:: Filling or justifying text. * Case:: Changing the case of text. * Text Mode:: The major modes for editing text files. * Outline Mode:: Editing outlines. * TeX Mode:: Editing input to the formatter TeX. * Nroff Mode:: Editing input to the formatter nroff. * Formatted Text:: Editing formatted text directly in WYSIWYG fashion.
Filling Text
* Auto Fill:: Auto Fill mode breaks long lines automatically. * Fill Commands:: Commands to refill paragraphs and center lines. * Fill Prefix:: Filling paragraphs that are indented or in a comment, etc. * Adaptive Fill:: How Emacs can determine the fill prefix automatically.
Editing Programs
* Program Modes:: Major modes for editing programs. * Lists:: Expressions with balanced parentheses. * List Commands:: The commands for working with list and sexps. * Defuns:: Each program is made up of separate functions. There are editing com- mands to operate on them. * Program Indent:: Adjusting indentation to show the nesting. * Matching:: Insertion of a close-delimiter flashes matching open. * Comments:: Inserting, killing, and aligning comments. * Balanced Editing:: Inserting two matching parentheses at once, etc. * Symbol Completion:: Completion on symbol names of your program or language. * Documentation:: Getting documentation of functions you plan to call. * Change Log:: Maintaining a change history for your program.
* Tags:: Go directly to any function in your program in one command. Tags remem- bers which file it is in. * Emerge:: A convenient way of merging two versions of a program. * C/Java Modes:: Special commands of C, C++, Objective-C and Java modes. * Fortran:: FORTRAN mode and its special features. * Asm Mode:: Asm mode and its special features.
Indentation for Programs
* Basic Indent:: Indenting a single line. * Multi-line Indent:: Commands to reindent many lines at once. * Lisp Indent:: Specifying how each Lisp function should be indented. * C Indent:: Choosing an indentation style for C code.
Tags Tables
* Tag Syntax:: Tag syntax for various types of code and text files. * Create Tags Table:: Creating a tags table with `etags'. * Select Tags Table:: How to visit a tags table. * Find Tag:: Commands to find the definition of a specific tag. * Tags Search:: Using a tags table for searching and replacing.
* List Tags:: Listing and finding tags defined in a file.
Merging Files with Emerge
* Overview of Emerge:: How to start Emerge. Basic concepts. * Submodes of Emerge:: Fast mode vs. Edit mode.
Skip Prefers mode and Auto Advance mode. * State of Difference:: You do the merge by specifying state A or B for each difference. * Merge Commands:: Commands for selecting a difference, changing states of differences, etc. * Exiting Emerge:: What to do when you've finished the merge. * Combining in Emerge:: How to keep both alternatives for a difference. * Fine Points of Emerge:: Misc.
Compiling and Testing Programs
* Compilation:: Compiling programs in languages other than Lisp (C, Pascal, etc.). * Compilation Mode:: The mode for visiting compiler errors. * Compilation Shell:: Customizing your shell properly for use in the compilation buffer.
* Debuggers:: Running symbolic debuggers for non-Lisp programs. * Executing Lisp:: Various modes for editing Lisp programs, with different facilities for run- ning the Lisp programs. * Lisp Libraries:: Creating Lisp programs to run in Emacs. * Lisp Interaction:: Executing Lisp in an Emacs buffer. * Lisp Eval:: Executing a single Lisp expression in Emacs. * External Lisp:: Communicating through Emacs with a separate Lisp.
Running Debuggers Under Emacs
* Starting GUD:: How to start a debugger subprocess. * Debugger Operation:: Connection between the debugger and source buffers. * Commands of GUD:: Key bindings for common commands. * GUD Customization:: Defining your own commands for GUD.
Abbrevs
* Abbrev Concepts:: Fundamentals of defined abbrevs. * Defining Abbrevs:: Defining an abbrev, so it will expand when typed. * Expanding Abbrevs:: Controlling expansion: prefixes, canceling expansion. * Editing Abbrevs:: Viewing or editing the entire list of defined abbrevs.
* Saving Abbrevs:: Saving the entire list of abbrevs for another session. * Dynamic Abbrevs:: Abbreviations for words already in the buffer.
Editing Pictures
* Basic Picture:: Basic concepts and simple commands of Picture Mode. * Insert in Picture:: Controlling direction of cursor motion after "self-inserting" characters. * Tabs in Picture:: Various features for tab stops and indentation. * Rectangles in Picture:: Clearing and superimposing rectangles.
Sending Mail
* Mail Format:: Format of the mail being composed. * Mail Headers:: Details of permitted mail header fields. * Mail Aliases:: Abbreviating and grouping mail addresses. * Mail Mode:: Special commands for editing mail being composed. * Distracting NSA:: How to distract the NSA's attention. * Mail Methods:: Using alternative mail-composition methods.
Reading Mail with Rmail
* Rmail Basics:: Basic concepts of Rmail, and simple use. * Rmail Scrolling:: Scrolling through a message. * Rmail Motion:: Moving to another message. * Rmail Deletion:: Deleting and expunging messages. * Rmail Inbox:: How mail gets into the Rmail file. * Rmail Files:: Using multiple Rmail files. * Rmail Output:: Copying message out to files. * Rmail Labels:: Classifying messages by labeling them. * Rmail Attributes:: Certain standard labels, called attributes. * Rmail Reply:: Sending replies to messages you are viewing. * Rmail Summary:: Summaries show brief info on many messages. * Rmail Sorting:: Sorting messages in Rmail. * Rmail Display:: How Rmail displays a message; customization. * Rmail Editing:: Editing message text and headers in Rmail. * Rmail Digest:: Extracting the messages from a digest message. * Out of Rmail:: Converting an Rmail file to mailbox format. * Rmail Rot13:: Reading messages encoded in the rot13 code. * Movemail:: More details of fetching new mail.
Dired, the Directory Editor
* Dired Enter:: How to invoke Dired.
* Dired Commands:: Commands in the Dired buffer. * Dired Deletion:: Deleting files with Dired. * Flagging Many Files:: Flagging files based on their names. * Dired Visiting:: Other file operations through Dired. * Marks vs Flags:: Flagging for deletion vs marking. * Operating on Files:: How to copy, rename, print, compress, etc. either one file or several files. * Shell Commands in Dired:: Running a shell command on the marked files. * Transforming File Names:: Using patterns to rename multiple files. * Comparison in Dired:: Running `diff' by way of Dired. * Subdirectories in Dired:: Adding subdirectories to the Dired buffer. * Subdirectory Motion:: Moving across subdirectories, and up and down. * Hiding Subdirectories:: Making subdirectories visible or invisible. * Dired Updating:: Discarding lines for files of no interest. * Dired and Find:: Using `find' to choose the files for Dired.
The Calendar and the Diary
* Calendar Motion:: Moving through the calendar; selecting a date. * Scroll Calendar:: Bringing earlier or later months onto the screen. * Counting Days:: How many days are there between two dates? * General Calendar:: Exiting or recomputing the calendar.
* LaTeX Calendar:: Print a calendar using LaTeX. * Holidays:: Displaying dates of holidays. * Sunrise/Sunset:: Displaying local times of sunrise and sunset. * Lunar Phases:: Displaying phases of the moon. * Other Calendars:: Converting dates to other calendar systems. * Diary:: Displaying events from your diary. * Appointments:: Reminders when it's time to do something. * Daylight Savings:: How to specify when daylight savings time is active.
Movement in the Calendar
* Calendar Unit Motion:: Moving by days, weeks, months, and years. * Move to Beginning or End:: Moving to start/end of weeks, months, and years. * Specified Dates:: Moving to the current date or another specific date.
Conversion To and From Other Calendars
* Calendar Systems:: The calendars Emacs understands (aside from Gregorian). * To Other Calendar:: Converting the selected date to various calendars. * From Other Calendar:: Moving to a date specified in another calendar.
* Mayan Calendar:: Moving to a date specified in a Mayan calendar.
The Diary
* Diary Commands:: Viewing diary entries and associated calendar dates. * Format of Diary File:: Entering events in your diary. * Date Formats:: Various ways you can specify dates. * Adding to Diary:: Commands to create diary entries. * Special Diary Entries:: Anniversaries, blocks of dates, cyclic entries, etc.
GNUS
* Buffers of Gnus:: The group, summary, and article buffers. * Gnus Startup:: What you should know about starting Gnus. * Summary of Gnus:: A short description of the basic Gnus commands.
Running Shell Commands from Emacs
* Single Shell:: How to run one shell command and return. * Interactive Shell:: Permanent shell taking input via Emacs.
* Shell Mode:: Special Emacs commands used with permanent shell. * Shell History:: Repeating previous commands in a shell buffer. * Shell Options:: Options for customizing Shell mode. * Remote Host:: Connecting to another computer.
Customization
* Minor Modes:: Each minor mode is one feature you can turn on independently of any others. * Variables:: Many Emacs commands examine Emacs variables to decide what to do; by setting variables, you can control their functioning. * Keyboard Macros:: A keyboard macro records a sequence of keystrokes to be replayed with a single command.
* Key Bindings:: The keymaps say what command each key runs. By changing them, you can "redefine keys". * Keyboard Translations:: If your keyboard passes an undesired code for a key, you can tell Emacs to substitute another code. * Syntax:: The syntax table controls how words and expressions are parsed.
* Init File:: How to write common customizations in the `.emacs' file.
Variables
* Examining:: Examining or setting one variable's value. * Easy Customization:: Convenient and easy customization of variables. * Hooks:: Hook variables let you specify programs for parts of Emacs to run on par- ticular occasions. * Locals:: Per-buffer values of variables. * File Variables:: How files can specify variable values.
Keyboard Macros
* Basic Kbd Macro:: Defining and running keyboard macros. * Save Kbd Macro:: Giving keyboard macros names; saving them in files. * Kbd Macro Query:: Making keyboard macros do different things each time.
Customizing Key Bindings
* Keymaps:: Generalities. The global keymap.
* Prefix Keymaps:: Keymaps for prefix keys.
* Local Keymaps:: Major and minor modes have their own keymaps. * Minibuffer Maps:: The minibuffer uses its own local keymaps. * Rebinding:: How to redefine one key's meaning conveniently. *Init Rebinding:: Rebinding keys with your init file, `.emacs'. * Function Keys:: Rebinding terminal function keys. * Named ASCII Chars:: Distinguishing <TAB> from `C-i', and so on. * Mouse Buttons:: Rebinding mouse buttons in Emacs. * Disabling:: Disabling a command means confirmation is required before it can be exe- cuted. This is done to protect beginners from surprises.
The Init File, `~/.emacs'
* Init Syntax:: Syntax of constants in Emacs Lisp. * Init Examples:: How to do some things with an init file. * Terminal Init:: Each terminal type can have an init file. * Find Init:: How Emacs finds the init file.
Dealing with Emacs Trouble
* DEL Gets Help:: What to do if <DEL> doesn't delete.
* Stuck Recursive:: `[...]' in mode line around the parentheses * Screen Garbled:: Garbage on the screen. * Text Garbled:: Garbage in the text. * Unasked-for Search:: Spontaneous entry to incremental search. * Memory Full:: How to cope when you run out of memory. * Emergency Escape:: Emergency escape— what to do if Emacs stops responding. * Total Frustration:: When you are at your wits end.
Reporting Bugs
* Criteria: Bug Criteria. Have you really found a bug? * Understanding Bug Reporting:: How to report a bug effectively. * Checklist:: Steps to follow for a good bug report. * Sending Patches:: How to send a patch for GNU Emacs.
Command Line Options and Arguments
* Action Arguments:: Arguments to visit files, load libraries, and call functions. * Initial Options:: Arguments that take effect while starting Emacs. * Command Example:: Examples of using command line arguments.
* Resume Arguments:: Specifying arguments when you resume a running Emacs. * Environment:: Environment variables that Emacs uses.
* Display X:: Changing the default display and using remote login. * Font X:: Choosing a font for text, under X. * Colors X:: Choosing colors, under X. * Window Size X:: Start-up window size, under X. * Borders X:: Internal and external borders, under X. * Title X:: Specifying the initial frame's title. * Icons X:: Choosing what sort of icon to use, under X. * Resources X:: Advanced use of classes and resources, under X. * Lucid Resources:: X resources for Lucid menus. * Motif Resources:: X resources for Motif menus.
Environment Variables
* General Variables:: Environment variables that all versions of Emacs use. * Misc Variables:: Certain system specific variables.
|
Share This