1.1. Emacs Basics

1.1.1. A Word About Modes

Emacs achieves some of its famed versatility by having various editing modes in which it behaves slightly differently. The word mode may sound technical or complicated, but what it really means is that Emacs becomes sensitive to the task at hand.

Text mode and C mode are major modes. A buffer can be in only one major mode at a time; to exit a major mode, you have to enter another one.

1.1.1.1. Major modes

Whenever you edit a file, Emacs attempts to put you into the correct major mode. If you edit a file that ends in .c, it puts you into C mode. If you edit a file that ends in .el, it puts you in LISP mode.

Major Mode    Function
Fundamental mode    The default mode; no special behavior
Text mode    For writing text
Mail mode    For writing mail messages
RMAIL mode    For reading and organizing mail
View mode    For viewing files but not editing
Shell mode    For running a UNIX shell within Emacs
Telnet mode    For logging in to remote systems
Outline mode    For writing outlines
Indented text mode    For indenting text automatically
Nroff mode    For formatting files for nroff
TeX mode    For formatting files for TeX
LaTeX mode    For formatting files for LaTeX
C mode    For writing C programs
C++ mode    For writing C++ programs
Java mode    For writing Java programs
FORTRAN mode    For writing FORTRAN programs
Emacs LISP mode    For writing Emacs LISP functions
LISP mode    For writing LISP programs
LISP interaction mode    For writing and evaluating LISP expressions

1.1.1.2. Minor modes

In addition to major modes, there are also minor modes. These define a particular aspect of Emacs behavior and can be turned on and off within a major mode.

Minor Mode Function
Auto-fill mode Enables word wrap
Overwrite mode Replaces characters as you type instead of inserting them
Auto-save mode Saves your file automatically every so often in an auto-save file
Abbrev mode Allows you to define word abbreviations
Transient mark mode Highlights selected regions of text
Outline mode For writing outlines
VC mode For using various version control systems under Emacs

1.1.2. Starting and Leaving Emacs

To Keystrokes Command Name
Start Emacs emacs
Edit a specific file in Emacs emacs filename
Exit Emacs C-x C-c save-buffers-kill-emacs
Suspend Emacs temporarily C-z suspend-emacs

1.1.3. Working with Files

To Keystrokes Command Name
Open a file C-x C-f find-file
Open a different file instead C-x C-v find-alternate-file
Insert file at cursor position C-x i insert-file
Save a file C-x C-s save-buffer
Save a file under another name C-x C-w write-file
Create a new buffer C-x b buffername switch-to-buffer
Move to an existing buffer C-x b buffername switch-to-buffer
Display the buffer list C-x C-b list-buffers

1.1.4. Letting Emacs Fill in the Blanks

Emacs has a very helpful feature known as completion. If you open an existing file, type only the first few letters of the name, enough to make a unique filename. Press TAB, and Emacs completes the filename for you. Completion also works for long command names.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset