Spacemacs is a community developed configuration for Emacs that makes it easier for anyone to use this amazing developer tool. Spacemacs is a well thought out way to apply the vast and diverse power of Emacs, making it more accessible especially to those who are used to using Vi.
Unless you’ve spent the last few years hand-crafting your own Emacs configuration, then I think you will enjoy Spacemacs. Here are some reasons why I love Spacemacs as an Emacs user.
The startup for Spacemacs is really quick, less than 2 seconds, even after adding a whole host of features (layers). Some of this speed may be due to the lazy loading approach that Spacemacs takes. In the best tradition of Lisp, some things are only loaded in Spacemacs when they are first used. For example, when you open a Clojure source code file for the first time, the Clojure layer is loaded and clojure mode is applied.
The init.el file has long been the entry point for your Emacs configuration with many different ways to setup an Emacs configuration. With Spacemacs you have the
.spacemacs file and layers, giving a very structured approach that is easy to follow.
.spacemacs file has three sections
- dotspacemacs/init - configuration applied when Spacemacs first starts, eg evil or holy mode(emacs), themes, fonts, full screen, recent files, etc
- dotspacemacs/layers - add features to spacemacs using layers, a layer can contain elisp and packages from Melpa/Elpa
- dotspacemacs/config - additional layer configuration or your own customisations
The (emacs) keybindings for dotspacemacs are
M-m f e d - open the
M-m f e R - reload the configuration from
Some changes in the
~/.spacemacsfile still require a restart of Emacs , especially when pulling in a large number of packages in a layer.
Developers drive Emacs with keybindings or use commands via
M-x. The more features you add to Emacs, the more keybindings and commands you have at your fingertips. So to manage all this power, Spacemacs uses Helm to organise these keybindings & commands into groups. Helm also helps you navigate the file system too, minimising the need to type directory and file names in full.
Commands are grouped by their nemonic character, for example
g- git/version control
Helm is an incremental completion and selection
narrowing framework. Its the central control tower of Spacemacs, it is used to manage buffers, projects, search results, configuration layers, toggles and more.
Once you have learnt the Spacemacs groupings for Helm its really fast to do anything, so take a look at the Helm documentation wiki.
You can still type in command names using
M-x command-name too, if you know the name of the command you are looking for.
ido mode is still available in Spacemacs but by default it is over-ridden by Helm. You can enable ido using
dotspacemacs-use-ido tin the
.spacemacs, however this only replaces a few commands.
numbered buffers - each buffer gets a number in the status bar, allowing you to jump to any buffer using the
SPCand the buffer number, eg.
M-n 3jumps to buffer number 3.
smartparens and symbol balancing/highlighting - speeding up typing and reducing errors due to unmatched symbols. For most symbols in most modes a matching symbol is created. So if you type
(then a matching
)is created too. If you want to surround some existing text with a symbol pair, then simply highlight the text and press the opening symbol. A closing symbol is also highlighted when the cursor is at the opening symbol. Spacemacs also highlights the surrounding symbols, including any parents. So if you are in a nested list,
(parent code (nested code)), then if the cursor is on the nested code, both nested & parent symbols are highlighted.
smooth scrolling - unlike the traditional jump-scrolling of Emacs, Spacemacs uses smooth scrolling as you fing in most other text editors.
Here are a few basic steps I took when starting Spacemacs
With Emacs 24 installed I simply clone the Spacemacs configuration (first moving any existing Emacs configuration out of the way)
git clone --recursive https://github.com/syl20bnr/spacemacs ~/.emacs.d
Before running Emacs I switched to the
develop branch so I would have all the latest additions to Spacemacs (it seems pretty stable so far)
git checkout develop
Then I just ran Emacs as normal and saw Spacemacs taking shape. There were a number of Emacs packages to download, so this bit took about a minute.
I’ve been using Emacs for several years as my main browser so am very familiar with the Emacs bindings. So when first starting Spacemacs I naturally chose the holy mode (aka Emacs mode)
dotspacemacs/layers function in
After saving the changes to
~/.spacemacs the configuration was reloaded with
M-m f e R. As I installed a lot of packages, I also restarted Emacs once everything had finished.
Using Helm is an easy way to see what layers are already available in Spacemacs, using the keyboard combo
M-m f e h. This gives you a list of all layers and if you hit return on any of the layer names you are taken to the docs for that layer.
You can also create your own layers with
M-m configuration-layer/create-layer. See http://thume.ca/howto/2015/03/07/configuring-spacemacs-a-tutorial/ for more info as well as the Spacemacs docs.
I set the default font to Ubuntu 16, the smallest usable font for my laptop for my own use.
dotspacemacs-default-font '("Ubuntu Mono"
I often share my laptop with others or give a presentation using Emacs. So I’ve added two keyboard bindings I commonly used to increase & decrease the font size in the current buffer. This was added to the
dotspacemacs/config function in
(define-key global-map (kbd "C-+") 'text-scale-increase)
I like to see Emacs in full screen mode for minimum distraction, so I changed the following option in the
dotspacemacs/init function of
I really like the way Spacemacs is organised and have not felt the need to change anything, other than adding a few keybindings. Its obvious right from the start that Spacemacs has been well thought out. There is also a great community behind Spacemacs and there is always plenty of help.
There is still a lot to learn to get the most out of Spacemacs, but after a day I am pretty comfortable and productive. The biggest thing to try is probably the modal editing approach you get with Vi and other eVIl features of Spacemacs. This could make development with Emacs even faster.
It is well worth reading the Spacemacs guide, which I found easy to follow.
This work is licensed under a Creative Commons Attribution 4.0 ShareAlike License, including custom images & stylesheets. Permissions beyond the scope of this license may be available at @jr0cket