1. alex koval
  2. .emacs.d



Table of Contents generated with DocToc


hg clone https://bitbucket.org/avkoval/.emacs.d

Ubuntu requirements

Texinfo is needed for flycheck.

sudo apt-get install texinfo

Copy configuration file (optional)

To tweak configuration settings you should copy .emacs.d/init.el into your home directory .emacs (optional but recommended step):

cp .emacs.d/init.el ~/.emacs

Running emacs for beginners

Emacs strives for maximum power, and because of this it binds keys on very unusual key combinations. Beginners find it difficult to accomodate to different copy/paste behavior and some other things. But please be patient, if you overcome those problems, you will obtain more power in your hands.

Start from learning very standard non-customized emacs keys

Because you might need to run emacs without custom configuration on remote terminals and elsewhere you need to learn all standard keybindings first. Later, in your customized configuration you might want to override some for best productivity, but learning the core keys in the first stage is very important.

To excel in this, you need to follow those two simple steps:

A very short introduction to emacs keys:

Action Key
Exit emacs C-x C-c
Open file C-x C-f
Save file back to disk C-x C-s
Start mark C-SPC
Copy mark M-w
Paste mark C-y
Close buffer (kill buffer) C-x k
Next buffer C-x RIGHT
Previos buffer C-x Left
Buffer list C-x C-b
Next window C-x o
Keep 1 window C-x 1
Quit from some running emacs app q
Kill running emacs app C-g
About recursive edit (command line) C-]
Undo C-x u, C-_
Dired (file browser) C-x d


  • C = Control key
  • M = usually Alt key
  • S = Shift key

Notes on Emacs specific terms:

  • File is named 'buffer'
  • Selection Block is named 'region'
  • Window and Frame might mean opposite things

Situations which makes most novices lost

A new frame appears on screen, you have no idea how to exit it. Example:


  • You have opened some internal buffer. No need to worry, to return to single window view - press C-x 1
  • If you find yourself in wrong window, press C-x o first to move cursor to other window.

Your cursor at the bottom of screen, no idea how to get it back

Like this:

  • Press C-g. Should help. If does not: press C-] (several times). If cursor is not in the frame where your file is, use C-o until its returned.

My (avk) key bindings plus standard keybindings

(but look also in file:./configs/cfg_keybindings.el)

General editing keys:

Action Key Notes
Duplicate current line C-+ 'kill-ring' safe
Insert line above C-S-insert Control Shift Insert
Delete current line C-S-backspace 'kill-ring' safe
Delete current line (and yank) C-a C-k or select region and C-w
Comment or uncomment selected C-S-z
Match paren M+]
Scrolllock mode C-Scroll_Lock
Delete current buffer (close file) C-x C-k, M-DEL
Text position (3 pos) C-l
Delete whitespace C-z d
Suspend frame (go background) C-z C-z Std. combination for this action is C-z
but I need C-z for other things

Working with blocks (regions)

Action Key Notes
Select region C-SPC Or use Shift+cursor keys
Copy region M-w, C+INS Control-Insert
Yank (cut) region C-w
Insert region C-y, S+INS Shift-Insert

Named regions

In emacs you can copy selected region to a named memory place. So, this makes it possible to operate with different selected pieces of text.

Action Key Notes
copy to named memory register C-x rs CHAR Example: C-x r s 1
insert from named memory register C-x ri CHAR C-x r i 1

Function keys

Action Key Notes
Manual F1 same as man topic in console
Save F2
Open F3
Next window F6
Previous window S-F6
Query & replace in this buffer F7
Query & replace in files Contrl+F7
Next compilation error F8
Jump to bookmark C-F8
Ibuffer (open buffer=files list) and management F9
Menu F10
Toggle line numbers F11, C-z l
Toggle display of long lines F12

Quick switching between open buffers

I strongly sugges to enable cfg_helm.el in your custom copy of .emacs as its a primary additional module for switching between files and buffers.

Action Key Notes
Switch buffers C-x C-b Shows the list of open buffers
Switch buffers (helm enabled) via helm-recentf C-z C-r helm-recentf
Switch buffers C-z C-b
Switch buffers (Ibuffer) F9

helm specific keys

Excellent helm module Read more here provides reach functionality of switching between buffers, files, searching, etc.

Enable this by uncommending cfg_helm.el

Most important keys listed below:

Key Command What it does
C-c v helm-imenu Show document structure (functions, classes
s-‹ for Python)
C-c C-z helm-recentf Recentf is one of the most powerful emacs+helm
C-z C-r keybindings. Shows recently open files
C-c h p helm-projectile Find file in project
s-CPC helm-mini mini view with buffers, recentf combined
C-z C-a
C-c h m helm-mark-ring Shows recent locations in this file
C-z o helm-occur Shows occurencies of smth. in the file
C-c h a helm-ag A very fast search in files. First match like
a grep, 2nd match in helm
C-z f f helm-etags-select Etags search for project files. For python
C-z f t project you need to create tags first, use
create-TAGS emacs cmd
C-z C-f helm-find-files Find files using Helm. Rich functional
f3 via TAB.
C-z f a avk-change-default-font-fn My function to change font
C-c h b helm-bookmarks Bookmarks API to emacs bookmarks
C-c h f helm-firefox-bookmarks Firefox bookmarks
C-x c / helm-find Find files by name
C-c h r helm-resume Resume last helm screen

Misc keys

Action Key Notes
Change font (helm required) C-z fa
Change emacs skin (theme) C-z tt
Lower region C-x l
Upper region C-x u
Dired (show files) C-x d
Dired (by file mask) C-x d enter mask
ZTree (show files by tree) C-x z


Action Key Notes
Find in current file F7
Find in current file (occur) M-x occur
Find in current file (helm-occur) C-z o
Search in files C-F7
Search for file name C-S-D

Window switching

Action Key Notes
switch between windows F6
switch between windows WIN+Shift Arrow Keys

Plan for beginners (advanced level in 1 month of intensive usage)

Week 1 (use raw emacs in terminals and basic key bingings)

OK. On first week my general recommendation it to learn some basic keys and work in terminal. So, print out the PDF cheatsheet from Start from learning very standard non-customized emacs keys chapter, run throught tutorial and try emacs in remote terminals.

Week 2 (configuration tweaks, useful modules)

Be able to configure settings to own taste. Learn how emacs configuration works.

On this week you can learn how to tweak some emacs settings for your preference. This includes reassigning some keys for your taste (look for example in file:./configs/cfg_keybindings.el), and use configuration dialogs: M-x configure-variable and M-x configure-group.

Professional switching between open files, project files, search results

On this week you also have to study and be able to perform generic actions like:

  • Switch between files in project using helm (C-c h p)
  • Use dired:
    • C-x d start it, q - quit
  • Use ZTree
    • C-x z
  • Switch between open files using ibuffer (F9)
    • Learn how to close buffers (d), and how to execute action (x) in generic Emacs dialogs
    • How to sort s ...
    • How to filter / ...
  • Quick find file by name.
    • Using dired: C-S-d
    • Using helm: C-c x /
  • Find text in files:
    • Using rgrep (C-F7 and/or M-x rgrep)
    • Using silver search in project files: C-c s

Week 3 (advanced core modules usage)

  • Use / customize snippets (yasnippet) for your working environment
  • Edit files via sudo:// and <ssh://>
  • Advanced dired usage:
    • Find files by content
    • Mark/action on group files
    • Edit file names C-c C-q
    • ...
  • Use emacs shells for development and debugging using realgud debugger optional
  • Learn how to use emacs package manager: M-x package-list-packages

Week 4 - learn specific modules

In your work environment you might need or skip any of these, but generally I advice you to learn as its a very useful tools.


Magit is a bit of magic in emacs - it makes your daily work with 'git' so easy that you never come back using your console. It makes most of common operations quick and fast and group operations like squashing your commits or merging with conflicts became an easy task with Magic.

In my configuration Magit called via: C-z g and next you should try y to switch between branches or s to stage then c commit. At all, first thing to do is to press ? to see all actions. Magit really don't require a lot of documentation as most of features are self-explaining via context help.


Those who wish to maintain information structured and connected way org-mode provides it. The usage varies from preparing documentation, maintaining your tasks list to professional usage like maintaining results of some science experiments and evaluating external language blocks.

Your specific modes

For most of languages emacs have specific support which is called 'major mode'. For most common languages support is included into this configuration, but if you miss something, press M-x package-list-packages and look for your package. Language support packages called modes, like: python-mode or yaml-mode

Learn how to alter your configuration, use lisp snippets

Usually, your algorighm is this:

  • Google or try to find in emacs configuration (M-x configure-*) the settings you wish to change
  • Find Lisp example code, put into your configuration file (I usually suggest to split this to configs/cfg_*) try to execute with C-x C-e.