Guide to Setting Up Emacs for Development
May 04, 2014
Here is a guide that would help you to setup emacs.
First of all, If you are on Mac install emacs for OSX from here. you could easily install the GUI version of Emacs for other platforms too.
My Emacs config
This is my Emacs config which could be used for development in following technologies:
Ruby / Ruby on Rails
CSS / LESS / SASS / SCSS
HAML / Markdown / Textile / ERB
Clojure (via nrepl)
Common Lisp (with Slime)
This is my emacs live in action:
- Emacs 23 or greater (note that Emacs 24 is required for some functionality, and will likely become the minimum required version some time soon.)
To install, clone this repo to
~/.emacs.d, i.e. ensure that the
init.el contained in this repo ends up at
git clone https://github.com/vinitkumar/.emacs.d.git ~/.emacs.d
Upon starting up Emacs for the first time, further third-party packages will be automatically downloaded and installed.
Adding your own customization
To add your own customization, use M-x customize and/or
create a file
~/.emacs.d/lisp/init-local.el which looks like this:
... your code here ... (provide 'init-local)
Tips for using these emacs settings
If you want to use my settings straight out of the box, here are some things to note:
I recommend starting with a blank emacs + Technomancy’s better-defaults package, and then dig through this repo for useful nuggets, instead of forking it directly.
The key bindings are optimized for a norwegian keyboard layout.
Start by reading up on all the cool stuff in key-bindings.el.
You quit emacs with
C-x r q, mnemonic Really Quit.
Find file in project with
C-x o, in dir with
C-x C-f, recent with
Add your user- and project-specific stuff in .emacs.d/users/[machine name]/*.el
C-his rebound to backspace, like in the shell. Get help on
C-.(autocomplete entire lines with
expand-region is your friend. Find its bound key by doing
F1 f er/expand-region
C-_and redo with
M-_. Watch the undo-tree with
Quickly jump anywhere in the buffer with
C-øthen the starting letter of a word.
Indent and clean up white space in the entire buffer with
On a mac, the Meta key
Mis bound to Command.
I recommend rebinding Caps Lock to Ctrl and use that instead of the often badly placed Ctrl-key.
Survival guide for the first week of emacs
When you start using emacs for the first time, your habits fight you every inch of the way. Your fingers long for the good old familiar keybindings. Here’s an overview of the most commonly used shortcuts to get you through this pain:
CShorthand for the ctrl-key
MShorthand for the meta-key (bound to cmd on my mac settings)
SShorthand for the shift-key
C-x C-fOpen a file. Starts in the current directory
C-x fOpen a recently visited file
C-x oOpen a file in the current project (based on .git ++)
C-x C-sSave this file
C-x C-wSave as …
C-x C-jJump to this files’ current directory
C-x bSwitch to another open file (buffer)
C-x C-bList all open files (buffers)
Cut copy and paste
C-spaceStart marking stuff. C-g to cancel.
C-wCut (aka kill)
C-kCut till end of line
C-yPaste (aka yank)
M-yCycle last paste through previous kills
C-x C-yChoose what to paste from previous kills
C-@Mark stuff quickly. Press multiple times
C-gQuit out of whatever mess you’ve gotten yourself into
M-xRun a command by name
C-x uShow the undo-tree
C-x mOpen magit. It’s a magical git interface for emacs
C-arrowMove past words/paragraphs
C-aGo to start of line
C-eGo to end of line
M-g M-gGo to line number
C-x C-iGo to symbol
C-sSearch forward. Press
C-sagain to go further.
C-rSearch backward. Press
C-ragain to go further.
C-x 0Close this window
C-x 1Close other windows
C-x 2Split window horizontally
C-x 3Split window vertically
S-arrowJump to window to the left/right/up/down
F1 tBasic tutorial
F1 kHelp for a keybinding
F1 rEmacs’ extensive documentation
Credits & Inspiration
This config is totally based on this repo by Mr. Steve Purcell. But this might diverge with time and my personal taste.
The Survival guide has been taken from .emacs.d project of Mr. Magnar Sveen