On Spacemacs for Dummies

Since recently I’ve been trying to switch to using Spacemacs instead of Vim. As I had literally (in the literal sense) no Emacs experience, it wasn’t such a walk in the park as it’s presented to be. Here I want to share the basic lessons I’ve learnt to get over the initial barriers and start using the editor on a daily basis. Basically it’ll be a (very) short explanation how to accomplish my most common Vim tasks in Spacemacs.

Splitting windows

It’s super easy. First you split the window vertically (producing a vertical border through the whole screen) with SPC w v, or horizontally with SPC w - (the last character being a horizontal line). Afterwards you can switch between them with SPC w 1, SPC w 2, etc. and finally close them with SPC w c. Actually, closing a window is not final, because you can bring it back with SPC w u (undo).

Opening different files in your project

What I wanted is an equivalent of CtrlP that I’ve been using in Vim. For this we’re using the projectile library. Simply pressing SPC p f gives us a fuzzy-search of all the files in the current project. The exact scope of the project is being guessed. For me it usually comes down to the git repository the file I edit is in. You can also use SPC p r to switch to one of the recently opened files.

If I want to search for all the files containing come string, I use SPC s a p (search using ag in the project) this gets me a live-updated list of matches.

Renaming variables

What I used to do in Vim a lot is select the whole file, and then do :s/something/something else/. That was my elaborate way of renaming variables. Yeah, I know.

Anyway, I have an easier method now in Spacemacs where I move the cursor anywhere the variable that I want to rename, press SPC s e to go into iedit state, and then either I or A depending on whether I want to add a prefix or sufix. Afterwards I tap the ESC twice to go back to normal state.

All the rest

All the rest that I use are simple pure Vim commands that just work thanks to the Spacemacs’ evil mode. The above were the only things that I had to learn to be comfortable again in my editing after the switch. Hope it helps you as well!

Share on Twitter, Facebook
Prev Next