In this post I’m going to share my experience with Spacemacs – a GNU emacs configuration – and how it became my main editor from the first start. I will try to mention all those little things that I found convenient but had to discover myself, as I could not find them in a comprehensive guide.
My personal editor history
I use that keybindings everywhere I can, in my i3 environment, in mutt, or when browsing with Palemoon and the Pentadactyl plugin.
When doing larger coding projects, some functionality has to be added to vim though (for my taste), to make the editor more convenient and to solve simple and repeating tasks quicker. I found vim to become quite slow when packed with too many plugins, especially with Python auto-completion / introspection it was no fun to use anymore.
So I switched to sublime text, an excellent editor in my opinion – providing vim mode, hackable with Python code and very much customizable with json style settings. I loved it and still would use it, if only there wasn’t this little sting all the time; Although free to use, Sublime text will remind you every X savings you do, that you can buy a license (which is not even very expensive, 70$ for a superb product). This gave me a little stitch, not because good software has a price, but because it reminded me that I’m using non-free software again. So I decided to give GNU Emacs another try.
I had installed Emacs on my system before to check out what’s so nifty about it, that you would use it in favor of vim. I worked through the tutorial (which I can recommend to everyone, since you will meet Emacs keybindings everywhere – the Bash is my favorite example). However, the permanent use of the Ctrl and Alt/Meta key felt so inconvenient for me as vim user, not even evil mode could help it, and I abandoned Emacs.
I learned about Spacemacs in a #dgplug session and gave that a try. I was skeptic at first, but it turned out that Spacemacs felt so intuitive and convenient from the first use, that I stopped using any other editor in an instant.
However, the layer of abstraction that Spacemacs adds to Emacs is obvious. In Emacs, you can add features by adding a major mode and various minor modes to your buffer, and design a specific environment for all your specific tasks. That’s either copy and paste someone else’s config file to your own, or quite some time of fiddling with lisp.
Spacemacs does this by providing configuration layers, that will set up the major and minor modes and other things in the background for you already. So far I find this very convenient with nothing to miss for a nice workflow, no matter if I do Python coding, R scripting or writing my blogs or ToDos.
First things first
I updated my configuration layers by editing the config file: space f e d for file -> emacs -> dotfile I commented in all of the configuration layers that were out-commented per default, like autocompletion better-defaults git markdown and org etc. and added some others for my daily work: python, django, latex, ess (which is the R layer).
Although I added some snippets to my config file, I did not change the default behavior or keybindings, so everything I write here refers to default settings.
Similarly, space g will bring up a git (magit) menu (the best interface to git I have ever seen, by the way), given you have activated the git configuration layer in your dotfile.
With the projectile mode, space p shows options related to projects – e.g. every folder that contains a .git folder is considered a project. space p f will trigger a fuzzy search on files all over that project folder and sub-folders. I loved the ctrl+shift+p keybinding in Sublime text, that just did that and was happy not to have miss that feature. space m shows the options of your currently activate major mode. In Python mode for example, it will provide me with options of jumping to definitions, open a REPL, execute code, etc. Since the major mode may be used quite frequently, you can just type , to abbreviate the space m (it sounds ridiculous but it’s really nice to have).
In Emacs, you can assign keybindings to every function or macro of your choice. The keybindings change with the modes you activate, and of course they can be changed in your config files individually. To me, this seemed very chaotic and I found it difficult to remember all those key combinations. You can however call every function by name (given that you know the name). Spacemacs let’s you do the same thing, but by default lets you search for the desired function with a nifty fuzzy search. You can trigger that either with the original Emacs Alt x keybinding or by pressing space space. I do that very often for functions I don’t need to remember the key combinations, because I don’t use them too often. With the org2blog module, for example, I can login to my wordpress account to publish the post with only a few keystrokes from within Emacs. I simply type space space login to choose and execute the org2blog/wp-login function and space space publish to trigger org2blog/wp-post-buffer-and-publish.
In general, Emacs provides an excellent help, if you know how to pull it up. You might already guess it, you will find all help related options with space h. Here you can choose e.g. space to learn about the Spacemacs specific options and configuration layers. But what’s really cool is what you’ll find under space h d (for help -> describe). Here you can find help on any function f, mode m, package p and many more. Particularly helpful: space h d b let’s you fuzzy-type a function and shows you the keybindings to it. The other way round space h d k will let you type a keybinding to show you the documentation of the function it triggers.
Org mode is something I read of before, but never really could make sense of. Maybe that’s because it’s so versatile. It’s structured text very similar to markdown or rST; similarly you can export your .org files to a variety of formats (latex/pdf or beamer, html – plain or even with twitter bootstrap css and js, open office odt and many others). It also provides functionality to manage ToDo lists and agendas, schedule tasks and record progress. Writing tables and formatting any kind of text is super easy. What I find a very cool bonus: it is rendered by Github to perfectly beautiful sheets.
I went over to use it for my tasks at work but for my private appointments as well. The , to trigger the major mode commands comes very handy again.
You can create items with a simple asterisks. shift right/left will let you cycle through the todo sequence, so you can mark an item as TODO or DONE ect. You can nest those items with more asterisks, give them tags and define deadlines or schedule your tasks. To schedule you simply press , s, which will bring up a calendar to choose from. The interface is smart enough, however, to recognize most notations you type. To schedule the task for the next day, you could write +1, to put it on next Monday just type Monday (or even just mon) and hit enter. Type 1 sep if you want to schedule for September 1st. Same thing applies for deadlines , d.
You can have an arbitrary number of org files with tasks and ToDos of different domains. I have one for work and one for private stuff. With ctrl+c [ you can bring an org file to your agenda (actually I haven’t found a Spacemacs keybinding for that, yet). Your agenda can show you scheduled tasks and deadlines for the current week or provides other views and filters to not loose track. You can bring it up with , a a while in org mode (remember that , triggers major mode commands) or with space a o a (for apps -> org -> agenda) from any buffer and mode.
This blog is written in Org mode and transferred to WordPress.com with the org2blog module. All I have to add are some meta information. This can be done using the #+ tag. #+TITLE: <my title here> will add a title to my blog post.
If you use Emacs, I dare say you won’t be able to avoid elisp completely, if you want to customize the editor a bit to your needs. Emacs itself is largely written in lisp and is fully hackable if you know that language. Using Spacemacs, you probably won’t get in touch with elisp that often or intensively. If you want to add a configuration layer in the dotfile, you basically add an item to an elisp list, but you’ll hardly notice. Still, I would recommend to everyone to dive into that language if you consider using Emacs or Spacemacs for you all-day work. Apart from the fact that it’s a fascinating and historically important language, it will make your life easier if you know what you’re doing. The basics (syntax, builtin datatypes and functions) are learned quite quickly; the real big deal is about learning the third party functions – I’m still too new to the language to be able to oversee the countless possibilities, but I will dive deeper into it some time.