Linux Index

Emacs introduction


Introduction

Emacs is a powerful text editor. Especially suited for programming, it uses intensively the keyboard shortcuts. This page is a short summary of the most used shortcuts in Emacs. If you are configuring your Linux, you will appreciate that Emacs also works in text mode.

File access

Ctrl-x Ctrl-f
Open file
Ctrl-x Ctrl-s
Save

Buffer control

Ctrl-x k
Kill buffer (close file)
Ctrl-x b
Switch to an other buffer
Ctrl-x 2
Split the window vertically to see an extra buffer
Ctrl-x 3
Split the window horizontally to see an extra buffer
Ctrl-x 0
Hide the current window
Ctrl-x 1
Show only the current window
Ctrl-x o
Jump to an other window

Text editing

Ctrl-Space
Marks beginning of a block
Alt-w
Marks end of block and copy
Ctrl-w
Marks end of block and cut
Ctrl-y
Paste
Ctrl-a
Go to the beginning of the line
Ctrl-e
Go to the end of the line
Ctrl-k
Kill end of line (after the cursor)

General

Ctrl-g
Cancel the command you are typing
Ctrl-x Ctrl-c
Quit emacs
Ctrl-_
Undo
TAB
Automatic indentation (source code) while editing
TAB
Automatic completion while selecting a file or while typing a command in the mini-buffer
Alt-x
Type a command in the mini-buffer
Alt-x c-mode
Change major mode to c-mode
Alt-x global-font-lock-mode
Switch the 'global font lock mode' (highlights syntax)

Search and replace

Ctrl-s
Incremental forward search (press Ctrl-s again to search further)
Ctrl-r
Incremental backward search (press Ctrl-r again to search further)
Alt-%
Search and replace

Multiple files search

Simple search

Alt-x grep
Perform a 'grep' search
Alt-x grep-find
Perform a search using 'find' and 'grep'

Tags (for programmers)

find . -name "*.[ch]" | etags -
Make a TAGS index file for every file whose name ends with '.c' or '.h', starting from the current directory (this is a shell command !)
Alt-x visit-tags-table
Load a TAGS file
Alt-.
Find a tag
tags-search
Search through all files listed in the tags table
tags-query-replace
Search and replace through all files listed in the tags table
Alt-,
continue last tag search

Files comparison

Alt-x ediff
Compares two files

Spell check

Alt-x ispell-buffer
Spell check for the current buffer

Help

Ctrl-h ?
General help functions
Ctrl-h f
Describe the command you type
Ctrl-h a
apropos ... help based on a keyword
Ctrl-h m
Help on the current major mode