Well, how to begin is a question for philosophers, so I'm just going to
dig in and go for it. The first question you may ask is, "What exactly is
emacs?" And that would be a very good question. Some highbrow users may
raise their eyebrows and reply, "What isn't emacs?" But not here, we will
go into detail about the purpose, uses, and general basics of the emacs
editor.
As mentioned in that last sentence, emacs, in the most basic sense, is a
text editor. It allows you to create, edit, and save new or existing text
files on your machine. But its scope and power is not limited to mere
text editing. Emacs incorporates various operational modes specific to the
type of document that you are working on. This document is being written
in emacs under the text-mode. Other modes include HTML, C++, LISP, and
SCHEME.
"What," you may ask, "is the purpose of these operating modes?" Excellent
question! For now, let's just say that they make emacs smarter and
friendlier to use when editing these types of files. For any programmers
out there, can you say automatic parentheses matching?
By now, you have a very basic understanding of what emacs is and what it
is capable of. So, given that, let's start working with emacs.
Basic Commands in emacs
| Command Name |
Command Description |
| C-h k "command" |
Displays help on command (Ex C-h k C-l displays help on C-l
command) |
| C-h |
Displays help screen |
| C-v |
View next screen |
| M-v |
View previous screen |
| C-L or C-l (small case L) |
Clear screen and redisplay so text at cursor is in the center
of screen |
| C-b |
Moves cursor back one letter |
| C-f |
Moves cursor forward one letter |
| M-b |
Moves cursor back by one word |
| M-f |
Moves cursor forward by one word |
| C-p |
Moves cursor to previous line |
| C-n |
Moves cursor to next line |
| C-a |
Moves cursor to beginning of line |
| C-e |
Moves cursor to end of line |
| M-a |
Moves cursor to beginning fo sentence |
| M-e |
moves cursor to end of sentence |
| M-< |
Moves cursor to beginning of whole text or file |
| M-> |
Moves cursor to end of whole text or file |
| C-u number C-b/C-f/C-n/C-p |
Gives a numeric argument to the command (Ex: C-u 8 C-b moves
cursor back by 8 letters) |
| C-u num C-v |
Scrolls screen up by num lines |
| C-u num M-v |
Scrolls screen down by num lines |
| C-u num C-l |
Positions text at num lines from the top of screen |
| C-g |
Abort/Escape sequence to stop emacs from executing a command
or retyping the command |
| C-x 1 |
Kill all windows except the current one |
| C-x 2 |
Open a second window |
| C-M-v |
To scroll the bottom window |
| C-x-o |
To move cursor into the other window |
| C-x 4 C-f |
To find file and open it in second window |
| C-u num "string" |
Inserts "string" num number of times at the cursor |
| DEL |
Deletes character before the cursor |
| C-d |
Deletes the next character after the cursor |
| M-d |
Kill the word immediately after cursor |
| M-DEL |
Kill the word immediately before cursor |
| C-k |
Kill from the cursor position to end of line |
| M-k |
Kill from cursor position to end of sentence |
| C-x-DEL |
Kills from cursor position to the beginning of sentence |
| C-SPACE..C-w |
Kills the block marked by C-SPC and C-w |
| C-y |
Retrieve (Yank) text killed most recently (use this with
C-SPC..C-w to copy blocks) |
| M-y |
Yank texts killed earlier..yanks all killed texts in that
session |
| C-x num C-u |
Undoes the changes made by num number of commands |
| C-x C-f |
Find file |
| C-x C-s |
Save file |
| C-x C-b |
List buffers open in emacs currently |
| C-x s |
Save buffers interactively |
| C-z |
Suspend emacs |
| fg or %emacs |
Bring back emacs |
| M-x |
Used to enter named extended commands (ex: replace strings,
change modes etc) |
| C-s |
Initiate incremental search |
| ESC ESC ESC |
similar to C-g but more general "all-purpose get-out
command" |
| C-x C-c |
To exit emacs permanently |