Emacs

From AdminWiki

(Difference between revisions)
Jump to: navigation, search
Line 5: Line 5:
== Installation ==
== Installation ==
-
Graphical and text-only versions exist, I strongly recommend the graphical version because of a lot of added features.
+
Graphical and text-only versions exist, I strongly recommend the graphical version because of a lot of added features. The main distributions of emacs are "GNU Emacs" and "xemacs". I recommend GNU Emacs. Make sure you do not grab the "nox" (no X Window System support) packages, unless you really want to (emacs-nox is actually contained in the graphical package).
== Getting Started ==  
== Getting Started ==  
-
Without customization emacs is not better than any other editor. So in order to get started I suggest you grab yourself a .emacs.
+
Without customization emacs is no better than any other editor. So in order to get started I suggest you grab yourself a .emacs.
Here's mine: http://amd.co.at/fanopanic/dotemacs-0.0.2.tar.gz
Here's mine: http://amd.co.at/fanopanic/dotemacs-0.0.2.tar.gz
 +
You should replace every occurrence of "dot" in file/directory names with a literal dot, and move it into your homedir. Typically emacs should accept this configuration on any Unix with X Window System. Under Windows editing is probably necessary.
 +
 +
=== Modes ===
 +
The behaviour of emacs is defined by major and minor modes. Major modes alter it significantly, e.g. Lisp, Prolog, Makefile, ... mode, and only one can be active at a time. Minor modes are generally less unobtrusive, e.g. a spellchecker, or an auto-completer.
 +
 +
=== No heading yet ===
 +
In Emacs _everything_ you can do is actually a function that is called when you type a specific key sequence, even trivial things like "Cursor up" are bound to a function, in this case "previous-line". So when you forgot the key sequence for a command you can call the function directly using Meta-x (usually written M-x) and then typing the functionname. In most cases ALT is your Meta key. ESC serves as an alternative Meta key. From this approach it follows that all keybindings can be changed.
 +
 +
=== Essential default keybindings ===
 +
C stands for Control
 +
M stands for Meta (usually ALT)
 +
H stands for Hyper (normally not used, you can map that useless CAPSLOCK onto Hyper with xmodmap)
 +
 +
Also note that the dotemacs package above contains a more elaborate keybindings cheatsheet.
 +
 +
C-x C-c  quit
 +
C-x C-s  save
 +
C-x C-f  open ("find") file
 +
C-g      aborts any keysequence you started
 +
 +
C-x C-u  undo last action (
 +
There is no explicit redo
 +
 +
You can open an arbitrary number of files. Switching between them means switching buffers.
 +
C-x b    switch to buffer (defaults to previous)
 +
C-x k    kill a buffer (defaults to current)
 +
C-x C-b  show buffer list
 +
 +
As soon as you opened the buffer list you will have noticed that emacs supports split-screens, or rather multiple windows. A window is not the same as a buffer. A buffer resides in a window. When you kill the window the buffer does not die with it. Instead it just stays in the buffer list.
 +
C-x o    switch to 'o'ther window
 +
C-x 1

Revision as of 01:38, 6 June 2006

Emacs is arguably the most powerful text editor in existence. It's power is derived from it's extensibility via Elisp.

Contents

Introduction

First of all: Emacs is not for everyone, and not for every task. In order to change a few characters in a textfile you are probably better off with a conventional editor like vim. Emacs is more like a multi-purpose development environment that you start in the morning and shut down in the evening, if at all.

Installation

Graphical and text-only versions exist, I strongly recommend the graphical version because of a lot of added features. The main distributions of emacs are "GNU Emacs" and "xemacs". I recommend GNU Emacs. Make sure you do not grab the "nox" (no X Window System support) packages, unless you really want to (emacs-nox is actually contained in the graphical package).

Getting Started

Without customization emacs is no better than any other editor. So in order to get started I suggest you grab yourself a .emacs. Here's mine: http://amd.co.at/fanopanic/dotemacs-0.0.2.tar.gz You should replace every occurrence of "dot" in file/directory names with a literal dot, and move it into your homedir. Typically emacs should accept this configuration on any Unix with X Window System. Under Windows editing is probably necessary.

Modes

The behaviour of emacs is defined by major and minor modes. Major modes alter it significantly, e.g. Lisp, Prolog, Makefile, ... mode, and only one can be active at a time. Minor modes are generally less unobtrusive, e.g. a spellchecker, or an auto-completer.

No heading yet

In Emacs _everything_ you can do is actually a function that is called when you type a specific key sequence, even trivial things like "Cursor up" are bound to a function, in this case "previous-line". So when you forgot the key sequence for a command you can call the function directly using Meta-x (usually written M-x) and then typing the functionname. In most cases ALT is your Meta key. ESC serves as an alternative Meta key. From this approach it follows that all keybindings can be changed.

Essential default keybindings

C stands for Control M stands for Meta (usually ALT) H stands for Hyper (normally not used, you can map that useless CAPSLOCK onto Hyper with xmodmap)

Also note that the dotemacs package above contains a more elaborate keybindings cheatsheet.

C-x C-c quit C-x C-s save C-x C-f open ("find") file C-g aborts any keysequence you started

C-x C-u undo last action ( There is no explicit redo

You can open an arbitrary number of files. Switching between them means switching buffers. C-x b switch to buffer (defaults to previous) C-x k kill a buffer (defaults to current) C-x C-b show buffer list

As soon as you opened the buffer list you will have noticed that emacs supports split-screens, or rather multiple windows. A window is not the same as a buffer. A buffer resides in a window. When you kill the window the buffer does not die with it. Instead it just stays in the buffer list. C-x o switch to 'o'ther window C-x 1

Personal tools