An introduction to emacs via Spacemacs

George Stefanis
George Stefanis
An introduction to emacs via Spacemacs

Why Emacs

I'm not going to bore you with things like "It's made in the 70s" and "It's super powerful" or any of those facts. For me it was because of org-mode. I read recently a book regarding a note taking method called Zettelkasten. The basic premise of the method is that every note you make you connect it with some other note, via tagging, and it eventually creates a graph. As you add more notes you can start identifying themes. This method is very nice for writing and researching on whatever themes excite you. Org-mode is excellent for that. So I needed to learn how to use Emacs

Installing

First you need to start with vanilla emacs. I did install it on Manjaro Linux via sudo pacman -S emacs. On my work mac laptop I did install it via brew doing brew install --cask emacs. Note here that if you omit --cask it won't be installed as a standalone app and it will only be available through your command line.

Next step is installing Spacemacs. There is a little bit of weirdness here. The master branch is stale and the development branch is in active development. The project started with the intention to have regular releases I guess but it ended up being a rolling release project. So we will be working with the development branch of it. Do git clone -b develop https://github.com/syl20bnr/spacemacs ~/.emacs.d and that's it.

You can now start emacs by going to the command line and pressing emacs. At this point emacs will ask you whether you want to choose evil, which means VI type of key bindings, or regular emacs keybindings. I chose evil and most people recommend that. It's the best of both worlds, nice vi bindings and great emacs keyboard shortcuts.

Configuration

Once you are done with the installation you might want to do a bit of extra configuration. To achieve that you need to access the dotfiles for emacs. Click space f e d. The space is where you see all the different emacs commands and apps in your disposal. It's a super user friendly way to find your way around in the beginning.

Once in the dotfile search for dotspacemacs-configuration-layers by clicking / dotspacemacs-configuration-layers. If you want to know more about vi keybindings I wrote a quick cheatsheet recently. In there you can un-comment (by deleting the two semi-colons) the line about org. You can also add more layers. In my case I've added one for javascript, one for python, markdown and so on. Once ready you will need to reload the configuration for the new packages to be installed. To achieve that press space f e R. That will reload your configuration. Alternatively you can just close emacs and reopen it.

Next steps

At this point you can start installing new layers. I did add treemacs that gives you that side bar for the project. The other important thing is to start playing around with the best git client there is, magit. To access magit do space g s to see the status. If one file needs staging go over it and press s and that stages it. Click c c and that commits the files you staged. Write your message, save and exit by doing :wq and finally once you are out press P u to push to origin.

Once you start building some understanding it's time to start toying around with org. That's an entire beast on its own though and I'll reserve my learnings for a different post.

Final thoughts

Emacs will not be replacing my IDE. We are in 2021 and VSCode and Intellij are too good to just drop them for emacs. What it will do though is help me edit my different blogs, help me connect my notes using Zettelkasten and generally work as a more powerful VI client.

Some people find Spacemacs very heavy and too slow. For those people there are several alternatives. The most popular seems to be Doom emacs which is somewhat more bare bones. Might eventually graduate there, for now though I believe that Spacemacs is a fantastic way to wet your toes in the deep sea called emacs.