Practical Emacs advices.

Abstract

This is guide to aid starting with emacs as software development environment.


Table of Contents

Intro
How to start, quit and other basic commands.
A. Not basic but useful commands

Intro

Many commands are available through main and context menu. Others are not. I will present below how to effectively use all of them from the keyboard and how quickly find necessary function name.

Emacs has of course menus on the menu bar as well as context menu. Many operations are accessible with mouse click. Emacs however offers something special for those who hate using mouse, who don't like wasting time switching from keyboard to mouse or those who works on poor terminals with keyboard only. All functions, operations and features are accessible from keyboard.

This feature significantly improves your work if you know how to use it. There are two ways to call emacs editor function with keyboard only:

  • Key sequence - many editor functions are binded to some keyboard sequence. Yes they are complex and long and difficult to remember at the beginning. But emacs has thousands of available functions and each additional package comes with big number of new ones. So to make it possible to use them and make it more easy to remember them thay are divided to categories. Each category starts with different sequence. Later in document I will show the most commonly used and necessary keybindings.

  • Function name - each editor function has own unique name. So all functions can be called directly by their name even if it is not binded to particular key sequence. It may seem strange and unefficient to call functions by their name. First how can I know necessary function name, second how can I remember thousand function names? I will also show how to use them efficient without knowledge about function name and how to call them faster even then with key bindings.

Next important element you should be familiar with is emacs window. It is divided into 4 main parts.

  1. Menu bar -

  2. Buffer window -

  3. Status line -

  4. Minibufer -

How to start, quit and other basic commands.

A. Not basic but useful commands

Table A.1. Useful emacs commands

Function nameKeys bindingDescription
repeat

 C-x z 

Repeat the previous emacs command. To repeat the command more than once, press additional z's.
switch-to-completions

 M-v 

Typing <PRIOR> or <PAGE-UP>, or `M-v', while in the minibuffer, selects the window showing the completion list buffer.
apropos-command'

 C-h a 

Display a list of commands whose names match REGEXP.
describe-key

 C-h k 

Display the name and documentation of the command that KEY runs.
describe-function

 C-h f 

Display documentation on the Lisp function named FUNCTION.
where-is

 C-h w 

Show which keys run the command named COMMAND.
mark-paragraph

 M-h 

Put region around current paragraph.
mark-whole-buffer

 C-x h 

Put region around the entire buffer.
point-to-register

 C-x r <SPC> 

Save position of point in register.
jump-to-register

 C-x r j 

Jump to the position saved in register.
copy-to-register

 C-x r s 

Copy region into register.
insert-register

 C-x r i 

Insert text from register.
bookmark-set

 C-x r m 

Set the bookmark named BOOKMARK at point.
bookmark-jump

 C-x r b 

Jump to the bookmark named BOOKMARK.
list-bookmarks

 C-x r l 

List all bookmarks.
scroll-all-mode

 none 

When Scroll-All mode is on, scrolling commands entered in one window apply to all visible windows in the same frame.
abort-recursive-edit

 C-] 

Quits recursive edit and also quits unfinished commad immediately.