I was a long user of Vim. Recently, I have started using Spacemacs. It is a community-driven distribution of Emacs, which is actually a configuration repository developed on GitHub. In this post, I will introduce some of its features and explain how I liked it.

My history with text editors

I started using Vim in 2011. It was six years ago. Note that I have never been a professional programmer or software developer and I didn’t have a chance to get a programming job. I just used Vim personally.

Before Vim, I had tried Emacs. I tried to learn GNU Emacs, because I found some articles by geeks who recommend Emacs as a programmer’s text editor. I thought Emacs could be useful, but it was too difficult for me to understand concepts in the text editor at that time, and the pinky problem was a more serious reason I would not use it daily. Therefore I gave up with it.

I learned Vim, and I found it to be much easier. I installed a lot of Vim plugins and wrote a vimrc. Emacs still looked better for editing markup documents such as XML, Markdown, and LaTeX, but for other use cases, Vim was good enough. Actually, I was not always satisfied with Vim, but it was due to my lack of skills, and not to Vim itself.

I also tried other editors such as Sublime Text and Atom. Atom looked nice for web development. It allowed me to quickly get started with a personal web front-end project. It was highly usable. However, Atom was heavy. Therefore I was back to Vim. Actually, I switched to NeoVim after Atom, because it has a better support for asynchronous processes and built-in terminal emulator. NeoVim is better than Vim, and I am still using it sometimes.

I found Spacemacs by chance while I was browsing Slant. Slant is a great starting point for searching applications. Surprisingly, Spacemacs was ranked as a better programming text editor with VIM keybindings than Vim, next to Atom. I gained an interest in it. I gave it a try and liked it. I have decided to make a switch. I am writing a blog post on it now.

Why Emacs is better than Vim

Spacemacs users say, “Stop editor wars and use the both!” However, there is SpaceVim now. Both solutions are trying to make the best of the two worlds, but why is an Emacs-based solution better than a Vim-based one? Spacemacs seems to be more popular than SpaceVim at present, but is there a possibility that the latter will be better than the former one soon? Probably not. I will explain why I bet on Emacs rather than on Vim.

Emacs Lisp

Emacs is, for the most part, written in Emacs Lisp. You can extend Emacs in Lisp. On the other hand, Vim can be extended in VimL. Both Emacs Lisp and VimL look different from other popular languages, but Emacs Lisp is much closer to a real programming language, while VimL is just a scripting language for Vim. As a matter of fact, Vim has bindings to other languages (like Python), and quite a few Vim plugins depend on this feature of Vim, but this indicates that VimL is not capable enough to extend the text editor. Emacs packages are written purely in Emacs Lisp. It is a language that gives you freedom, And having a single powerful language for extension is crucial for constituting a flexible ecosystem, which is the topic of the next sub-section.

Eco System

Emacs is way better than Vim as an extensible programming environment. This article by Steve Yegge explains why Emacs is superior. It is because Emacs is introspective and does not (usually) need reboot to make changes.

Org Mode

Org Mode is a personal organizer for Emacs. It does not look beautiful, but it is mature and has tons of features to help you stay organized. Unless you need teamwork, Org Mode is more powerful than modern web/mobile productivity apps.

Getting started

Instalation

The latest instruction is available from Spacemacs on GitHub.

Spacemacs is based on Emacs. You have to first install Emacs, and then to clone the repository of Spacemacs. Unless you are already using Emacs, you can simply clone the repository into ~/.emacs.d:

git clone https://github.com/syl20bnr/spacemacs ~/.emacs.d

Customization

Your Spacemacs configuration is located at either ~/.spacemacs or ~/.spacemacs.d/init.el. You can use SPC f e d to edit the file, and SPC f e R to reload it. You usually tweak dotspacemacs/user-init and/or dotspacemacs/user-config (mostly the latter) to customize Spacemacs.

For details, read Dotfile Configuration in the documentation.

Spacemacs is structured under the notion of layers. You can add layers developed by the community, or you can create a new layer on your own.

What’s awesome with Spacemacs

Mnemonic keybindings

The keybindings of Spacemacs are consistently organized under SPC (Space) prefix key. The conventions are described in key bindings conventions.

A mini pop-up window is shown as you type prefix keys, so you don’t have to remember all of its keybindings.

Spacemacs keybindings under SPC key

Good defaults

As Spacemacs is actively developed by its community, it ships with plenty of features by default. You don’t have to spend a lot of time configuring the system for basic use, and you can extend it by selecting layers prepared by the community.

The following a list of some notable layers I especially liked. I recommend you turn on them from the beginning.

  • Helm, an incremental completion and selection narrowing framework. Helm is great. I suggest you read A Package in a league of its own: Helm. Remember, when you select a file in Helm, you can preview the file under cursor with <Tab>, and open the file under cursor in other window with C-c (enter a transient state) and then o.
  • Git layer based on Magit and other packages. It is so powerful that I like it even more than fugitive for vim.
  • Auto completion just works out of the box.
  • If you need a terminal emulator inside Emacs, turn on shell layer and run one of term, ansi-term, or multi-term from M-x. These emulators are not as good as that of NeoVim but suffice for running simple CLI applications. Of these, I especially like multi-term. If you just want to run a UNIX shell, you can use shell instead. There is also eshell, which allows you to run both shell commands and Emacs Lisp expressions in a single session. This article provides a simple overview of shells in Emacs.
  • Org Mode is an extremely useful personal organizer that runs inside Emacs. I will write a separate article (or series of articles perhaps) on how to configure and use Org mode.
  • You can edit text areas in Chrome browser using Emacs after setting up chrome layer and Edit with Emacs Chrome extension.

Spacemacs also ships with layers for integrating with external tools such as Vagrant and Ansible. Just check the list of layers to see if Spacemacs supports a certain feature you need.

What’s wrong with Spacemacs

I found almost nothing wrong with Spacemacs. Some of the keybindings provided by Spacemacs are redundant: I prefer M-x over SPC SPC, and <F1> is easier than SPC h d to remember and type, which are used to describe functions/variables/bindings/etc. You can avoid them by just sticking with the standard Emacs keybindings, so they never get in the way.

Some Vim keybindings are not available on Spacemacs, but this issue is not fatal at present. I have to learn more Spacemacs bindings or maybe “the Emacs way” of doing things.

I also found that some line-editing bindings are not available. I use C-a and C-e to jump to the beginning and end of the line, respectively, and C-w to kill the last word. These bindings should be provided by better defaults layer, but it did not work as I expected in hybrid mode and mini-buffers. I am probably going to configure those bindings for myself.

These keybinding issues can be resolved easily and are not design flaws at all. Therefore I can conclude that there is nothing wrong with Spacemacs.

Conclusion

My initial impression on Spacemacs is that it is impressive. I spent a whole lot of time configuring Vim and trying to compose things for workflows, but I was not successful in it. It is painful to switch contexts between many different systems and applications. Unlike Vim, which follows the UNIX philosophy of “doing one thing well”, Emacs can do (almost) everything, which in turn allows you to live in it. I am currently trying to use Org Mode for organizing my personal tasks, and it, of course, natively integrates with Emacs. With Org Mode, which organizes things inside Emacs, and Spacemacs, which is an efficient way to interact with Emacs, these pieces of software as a whole will allow you to organize work in a seamless manner.

I have not yet used Spacemacs for any programming projects except for writing some Emacs Lisp for customization, but I don’t worry much about that, as the community of Emacs is large and mature, and Spacemacs seems to offer layers for most major programming languages. Hopefully, Emacs with Spacemacs will serve as a whole suite of productivity and make my life finally “work”.

To learn more about Spacemacs, the documentation is an awesome point to start.