“Emacs is the extensible, customizable, self-documenting real-time display editor.”

-- GNU Official Website

In short, in contradiction to the other editors where editing was line by line (line editors), Emacs is a visual editor that you have a representation of your entire document on your screen, and you can move around freely, editing any part of the document you wish. Some of the features of GNU Emacs include:

Content sensitive major modes for a wide variety of file types, from plain text to source code to HTML files.
Complete online documentation, including a tutorial for new users.
Highly extensible through the Emacs Lisp language.

Conventions used in Emacs:
Emacs uses control and escape characters to distinguish editor commands from text to be inserted in the buffer. When we say “ CTRL-X ” it means to hold down the control key, and type the letter x. “ESC-X ” means to press the escape key down, release it, and then type x.

Working with buffers
The best things about programming in Emacs is ,when you edit a file in emacs, you’re not really editing the file itself, as it sits out on a disk somewhere. Instead, emacs makes a copy of the file, and stores the copy in a part of RAM memory called a buffer. All the changes you make to the file are applied to the buffer. When you save the file, emacs writes the contents of the buffer to the disk.

Because the buffer exists in RAM memory, it disappears if the power is turned off, or if the system crashes. Thus, you should use the save command often, flushing your current buffer to disk. Once the file is on disk, a power outage or system crash shouldn’t harm it.

The buffer files are usually represented as the Original file name ending with ‘ ~ ’ (tilda).

<machine>% ls

Makefile     test1.c     test.c      test1.c~

Basic operations in emacs
Here are some of the fundamental things you’ll need to do when you edit a document in emacs.

Starting emacs
To start emacs, just type the command at the command prompt.

<machine>% emacs

to the UNIX shell. If you want emacs to start with a file already loaded into a buffer, type

<machine>% emacs filename

Quitting emacs
To exit emacs and return to the UNIX shell, type CTRL-X-CTRL-C. Press control key and press ‘X’ and then again with the control key pressed , hit ‘c’. If you have made changes to the buffer since the last time you saved it to disk, emacs will ask you if you want to save. Type y for yes or n for no.

Getting help
Emacs has an on-line help system that can be invoked by typing CTRL-H. If you type the question mark (?), emacs will present a list of help topics you can choose.

Aborting a command
You can abort an emacs control or escape sequence by typing the command CTRL-G.

Working with files
To read a disk file into an emacs buffer, type the command CTRL-X-CTRL-F. Emacs will ask you for the name of the file. When you have entered the file name, press the return key, and emacs will load the file into a buffer, and display it in the text window.

The command to save the contents of the buffer to a disk file is CTRL-X-CTRL-S. The save command overwrites the old version of the file. You may also write the contents of the buffer to a different file with the command CTRL-X-CTRL-W. Emacs will prompt you for the name of the file you want to create.

To create a new file, use CTRL-X-CTRL-F, just as if the file already existed. When emacs asks you for the file name, type in the name you want your new file to have, and emacs will create the file, and display an empty buffer for you to type in. Emacs will perform file name completion for you. Type part of the name of the file you want, and press the spacebar or tab key to get emacs to complete a file name. If the partial name you’ve given matches more than one file, emacs will display a list of all potential matches. You can continue typing in more of the file’s name, and pressing either file completion key, until you zero in on the file you want.

Cursor motion
On well-configured systems, you will find that the keyboard arrow keys will function correctly in emacs, moving you forward or backward one character at a time, and up or down one line at a time. If the arrow keys do not work, here’s how to accomplish the same functions:
CTRL-F moves the cursor forward to the next character.
CTRL-B moves the cursor back to the previous character.
CTRL-N moves the cursor to the next line.
CTRL-P moves the cursor to the previous line.
In addition to basic cursor motion, emacs provides some other handy cursor motion functions:
CTRL-A moves the cursor to the start of the current line.
CTRL-E moves the cursor to the end of the current line.
ESC-F moves the cursor forward to the next word.
ESC-B moves the cursor back to the previous word.
ESC-< moves the cursor to the start of the buffer.
ESC-> moves the cursor to the end of the buffer.

Inserting and deleting text
To insert text into a buffer, place the cursor where you want to start inserting text, and start typing away. If you want to insert the contents of another file into the current buffer, place the cursor at the desired insertion point, and type Control-X-I. Emacs will ask you for the name of the file you wish to insert.You may also insert text by cutting it from one place, and pasting it at the insertion point. See the next section for information on cutting and pasting.

Deleting text is easy. As you’d expect, the delete key deletes backward one character. Here are some other ways to delete text:
CTRL-D deletes forward one letter.
CTRL-K deletes from the point to the end of the line.
ESC-D deletes forward one word.
ESC-delete deletes backward one word.

Cutting and pasting text regions:
Emacs allows you to select a region of text, and perform cut and paste operations on the region. It uses a temporary storage area called the “kill buffer” to allow you to store and retrieve blocks of text. There is only one kill buffer in emacs, which means that you can cut text from one document, and paste it into another.

To define a region of text, place the cursor at one end of the region and press Control-spacebar. That sets the mark. Then, move the cursor to the other end of the region. The text between the mark and the cursor defines the region.

To cut a region of text, and place it in the kill buffer, use the command Control-W (think of Wipe).

The paste command is Control-Y. It Yanks the block of text from the kill buffer, and places it where the cursor rests. The Control-Y command only retrieves the most recently-cut block of text.

You can paste in earlier cuts by pressing ESCAPE-Y. The ESCAPE-Y command, used repeatedly, will take you back through several previous text blocks that were cut. The ESCAPE-Y command does not work unless you type Control-Y first.

You may copy a region of text into the kill buffer without cutting it. Define the text block by setting the mark at one end, and moving the cursor to the other end. Then type ESCAPE-W.

Undoing changes
It is possible to undo the changes you have made to a file by entering the command Control-_. (That’s Control-underscore. On some keyboards, you’ll have to hold down both the control and shift keys to enter the underscore character.)

Quick Reference :

Starting and exiting emacs

• When you type emacs file, where file is the name of the file you want to edit, or just

emacs, a window pops up

emacs file

• To exit emacs editor:


Manipulating files with emacs

CTRL-x CTRL-f read a file into an emacs buffer

CTRL-x CTRL-s save file to disk

CTRL-x i inserts another file into this file

CTRL-x CTRL-w writes buffer to a file you name (use this like "save as")

Moving around in emacs

CTRL-f move forward one character

CTRL-b move backward one character

CTRL-n move forward one line

CTRL-p move backward one line

M-f move forward one word

M-b move backward one word

CTRL-a move to the beginning of line

CTRL-e move to the end of the line

CTRL-v scroll to next screen

M-v scroll to previous screen

CTRL-x b move to another buffer

Changing and moving text

Backspace, or CTRL-d : delete the character behind or at the cursor

M-d : delete the next word

CTRL-k : delete to the end of the line

CTRL-@ or CTRL-SPC : mark the beginning of a region

CTRL-w : cut (wipe) from here to beginning of the region

CTRL-y : insert here what you last deleted/cut/copied

M-w : copy from here to beginning of the region (same effect as CTRL-w CTRL-y)

Abort and undo

CTRL-g aborts a partially typed or executing command

CTRL- _(underscore) undoes the last change (repeatedly using undo will undo the last several changes)

Using two windows

• Create two windows:

CTRL-x 2 (this will split your screen into two windows)

CTRL-x o (move in the bottom window; use the same command to get back into the

upper window; here o is the letter not zero)

CTRL-x 1 (to kill one window)

Other Editors 0r Help with unix

1. Text Editor

2. Vi editor

3. Pico Text Editor