How to use Linux Editor Emacs (Xemacs)

Emacs is the king of all editors.

Emacs stands for Editor MACroS. (GNU)-Emacs was written and is maintained by Richard Stallman, the first version is form 1975. It has become a de facto standard alongside vi.

Emacs is more than just a text editor. It is a complete system for development, communications, file management, and things you wouldn’t even imagine.

Emacs has an active development community numbering in the hundreds, and runs on Windows , Linux and Unix.

Files, Buffers and Windows

Files:

C-x C-f  Reads a file into an Emacs buffer
C-x C-s  Saves the current buffer
C-x C-c  Saves all modified buffers and exits Emacs

Buffers: In Emacs each open file is edited in a buffer.
Commands to switch between the different buffers
(there are also menu options):

C-x C-b  Prints a list of the available buffers
C-x b    Asks you which buffer to select

Windows: Buffers are displayed in windows (you can also use the mouse):

C-x 2    Splits the current window vertically into two.
C-x 3    Splits the current window horizontally into two.
C-x 1    Deletes all windows except the one with the cursor
C-x o    Moves you into an other window on the screen

Modes, Commands and Help

In emacs there is a mode for each file type
(among other uses, there is also a doctor mode).

Each mode has its own commands and short-cut-keys.
Type “M-x” (M=Meta=Alt) then a command name.
You can use tab to complete or to get list of possible completions..
Use the command “describe-mode” for info of the mode of the current buffer.

Help:

C-h               Displays help window
C-h C-h           Gives you help on help
M-x help          Displays help window (alternate method)
C-h t             Shows the tutorial
C-h a             Shows commands matching a string
C-h i             Enters the Gnu Info documentation browser
A-x manual-entry  Manual-entry for string under cursor
A-x ispell-buffer Spell checker
A-x doctor        Doctor

Panic: When things run out of control try:

C-g       Runs the command keyboard-quit
C-_       Undo

Editing

 

Moving around in the buffer

By char: By word: By line: By S-exp: By page:
Forward: C-f M-f C-n C-M-f C-v
Backward: C-b M-b C-p C-M-b M-v
Beginning: C-a M-<
End: C-e M->

Deleting/Killing (cutting text)

By char: By word: By line: By S-exp: By region:
Forward: C-d M-d C-k C-M-k C-w
Backward: Del M-Del

 

Copy and Paste

C-k       kill-line
C-y       insert
C-Space   mark
A-w       copy
C-w       cut

 

Search and Replace

C-s                  search
C-r                  search-backward
A-%                  query-replace
A-x replace-string   replace-string

C-M-s                isearch-forward-regexp
C-M-r s              isearch-backward-regexp
C-M-%                query-replace-regexp

Emacs Cheat Sheet

Leave a Comment

Your email address will not be published. Required fields are marked *

CAPTCHA * Time limit is exhausted. Please reload the CAPTCHA.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Scroll to Top