Emacs - howto

By: John McFarlane <john.mcfarlane@rockfloat.com>
Last updated: 07/18/2004 @21:00

Abstract:
This document is a beginners guide to emacs.



1. Install emacs

On gentoo installing emacs is quite simple:

root$ emerge emacs python-mode app-emacs/mmm-mode app-emacs/pgsgml app-emacs/tramp
        
If you use an X environment like gnome, kde, icewm, or fluxbox... emacs will defaultly open itself up in an ncurses style gui. I find this annoying personally, thus I added the following to my .bashrc file to make emacs open the old fashioned way:

alias emacs="emacs -nw"
        
I'm finished with this step

2. Open emacs for the first time

Type emacs from the a console (a fresh one if you altered your .bash rc file as suggested above) and you will be presented with the mighty emacs. The first thing you will want to do is fine a file to edit:

C-x C-f
        
This will give you a dialog in the bottom of emacs where you can type in the path to a file. If you have tramp installed, then you can do cool stuff like opening files over ssh like so:

ssh://user@host.com:/path/to/file
ftp://user@host.com:/path/to/file
I'm finished with this step

3. Keyboard commands


C-h                 = help
C-g                 = exit out of everything but the open buffers
C-x C-f             = file open
C-x k               = file close (kill the current buffer)
C-s                 = inline search (foreward)
C-r                 = inline search (backwards)
C-q TAB             = hard tab
C-h k               = this will prompt and describe any keymap
C-h m               = get valid keymaps for that mode
C-e                 = end of line
M-e                 = beginning of line
C-x 1               = show x number of buffers
C-v                 = scroll down
M-c                 = scroll up
C-x 2               = split window vertically
C-x 3               = split window horizontally
M-x replace-string  = replace from cusor to end of buffer
C-x b               = show buffer list (iswitchb is nice here)
C-SPACE             = mark starting point of cut/paste (includes character cursor is on)
C-w                 = cut (from mark to position to left of cursor)
M-w                 = copy (from mark to position to left of cursor)
C-y                 = paste
M-!                 = execute command
ESC-q		    = auto format text
C-x u		    = undo
    
I'm finished with this step

4. Modes


M-x describe-mode
M-x untabify
M-x tabify
M-x load-library RET tramp RET
    	
I'm finished with this step

5. Helpfull links on emacs

I'm finished with this step

Changelog: Date Description
07/18/2004 @21:00 Added a few more keyboard commands

This document was originally created on 02/11/2006


Conventions and tips for this howto document:
  1. Please understand that I don't really understand why anyone would use a text style editor over a graphical editor like SciTE, eclipse, or jedit. But it seems obvious that some people like it, thus I'm giving emacs an earnest try.

Disclaimer:
This page is not endorsed by gentoo.org or any other cool cats. Any information provided in this document is to be used at your own risk.