Three Awesome Spacemacs Features

For almost a year now, I have been using Spacemacs, an Emacs distribution designed to make Vim users and newcomers to Emacs comfortable in Emacs, as my daily text editor. I was initially hooked by the nearly flawless Vim emulation, which is the best I have used in any text editor. After I had gotten my feet wet, I fell in love with the pre-defined mnemonic shortcuts and amazing packages that are included in the distribution.

In this article, I am going to discuss a few of my favorite features in Spacemacs and the packages included with it.

Project-Wide Refactoring with helm-ag-edit

Spacemacs provides multiple ways to make project-wide edits, but my favorite by far is through the use of helm-ag-edit. This allows you to search for a term and compile every line that fits that search term into a single Emacs buffer. From here, there are multiple actions you can take:

  1. Edit each line individually
  2. Do a simple find and replace in the buffer
  3. Run a Vim/Emacs macro

In my opinion, this is better than traditional project refactoring since it allows you to make multiple changes at once on each line using macros. Also, since all of the search results are on one page, it makes it easy to notice unwanted changes and fix them. Lastly, none of the changes are final until you decide to save them.

In order to use helm-ag-edit:

  1. Enter a helm-ag buffer using SPC / or any related command.
  2. Search for something you want to edit. This can be regex or just a word.
  3. Don’t hit enter. Instead enter CTRL-c CTRL-e.
  4. Make your desired changes.
  5. Enter CTRL-c CTRL-C to save your changes.

If you’re more of a fan of normal project search and replace, Spacemacs offers that as well via Kprojectile-replace. Just enter SPC p R for a normal string search, or SPC p % for a regex search.

File Navigation with avy

avy is an Emacs plugin (included in Spacemacs) that allows you to easily jump to places in a file. It provides simple shortcuts that allow you to jump to characters (avy-goto-char), words (avy-goto-word-or-subword), and lines (avy-goto-line). This is better than traditional searching with backslash since you can jump directly to the desired point.

avy-goto-char can be used by pressing SPC j j, then pressing the character that you want to jump to. After this, every occurrence of the character you pressed will be highlighted with a string of characters. To jump to the desired character, press the sequence of characters that is highlighting the location where you want to go.

Git workflow with Magit

One of my favorite plugins with Spacemacs is the Git integration Magit. It provides all of the common Git functionality in just a few keystrokes. On top of that, it provides visual interfaces that are extremely helpful through diffing, checking untracked files, and handling merge conflicts.

The first step to utilizing Magit is to enter the Magit status window by pressing SPC g s. In this window, you are given a list of all of the unstaged and staged files.  You can stage/unstage them by hovering over them and pressing s or u respectively.

Commands can also be entered in this window. For example, if you wanted to stage and commit all unstaged files, then push them to the current branch, you would press c -a c,  type and save your commit message,  press p p, then hit enter. This will commit your changes and push to the remote.

If you want to find out how to do more commands with Magit, either look at the documentation, or press SPC g m to see a help menu with a list of guided commands.


There are many more features built into packages included in Spacemacs. If you’re a Spacemacs user, or you are thinking about giving it a try, I highly recommend taking the time to read the documentation and looking for ways to optimize your development workflow.

  • drew verlee says:

    Thanks for the overview!

    I can’t seem follow the instructions above and enter a ag buffer

    Im using spacemacs 24.5. When i press
    “SPACE \” i get “undefined”. I’m in clojure mode when this happens if that matters.

    • Gage Vander Clay Gage Vander Clay says:

      Hey Drew,

      It looks like I made a typo. It’s supposed to be “SPACE /” not “SPACE \”. I just updated the post.

      Thanks for reading the blog post and pointing that out!

  • Lalit Kumar says:

    Hey Clay,

    I was trying to try Project-Wide Refactoring with helm-ag-edit

    I was trying to use “cgn” text-object of vim. But it’s giving me the error that “next-match text-object can only be used in evil-search-module”

    Can you help me why it is giving this error?

    I tried to fix this by
    (setq evil-search-module ‘evil-search)

    but it is not working.

    Thank you.

  • Comments are closed.