Skip to content

Spacemacs Reference Document

A general reference for getting into spacemacs from vim. Mostly derivative of other guides.

Table of Contents

This does not have all sections listed, just main sections and popular reference areas.

  1. Reference
    1. Notes
      1. Spacemacs State Color Codes
  2. Spacemacs Fixes
  3. Greg's elisp notes
  4. Why I switched

Reference

Useful Sequences

  1. See all active minor-modes and major mode: C-h m
    1. another get major-mode: C-h v major-mode
    2. another get minor-mode: C-h v minor-mode-list
    3. spacemacs minor-mode stuff
  2. Reload stuff/settings: SPC f e R
  3. Load up non-GUI mode: $ emacs -nw
  4. Insert any character: C-q
  5. Increment by q (q=1 by default): q SPC n -
    • has some sort of minor mode where you can keep pressing stuff, try it
  6. Clear search highlighting: SPC s c
  7. Navigate buffers: SPC b b
    • Check out the Messages buffer
    • kill buffer: SPC b d
    • next or prev buffer: SPC b n or SPC b p
  8. Jump between matched tags: %
  9. Exit insert mode (evil-escape): fd
    • note that this should take you to evil normal mode from anywhere
    • this may work identically to C-g
  10. Find a file and open in a new buffer: SPC f f
  11. "help describe": SPC h d
    • "help describe function" SPC h d f
    • "help describe key" SPC h d k
  12. guide-key, a menu of stuff: SPC
  13. Insert lorem ipsum: SPC i l l
    • (lorem-ipsum) has several nice insert options SPC i l
  14. Note that the vim . repeater works on SPC-leader macros..
    • try SPC i l l . . . . .
  15. Using evil-nerd-commenter
    • comment or uncomment a block of lines SPC c l
    • toggle comment on each line in a block of lines SPC c ;
      • can be used to simultaneously uncomment and comment neighboring lines
  16. SPC m is aliased to , and accesses the current major-mode menu

Interesting Sequences

  1. Incremental Search: C-s stuff
    • Note: / style search is already incremental in spacemacs.
  2. Learn emacs lisp: SPC h i elisp RET

Future

  1. Mess with iedit and iedit-insert states
  2. Try out the other SPC s search options
  3. Test out spacemacs regex SPC x which uses pcre2el package
  4. editing lisp code & lisp keybindings
  5. managing projects
  6. compiling code

External References

  1. Spacemacs documentation
  2. Migrating from Vim
    1. Remapping keys
  3. guide-key
  4. learn elisp in 15 minutes
  5. GNU emacs manual
  6. Configuration "Tutorial" Orientation for contributing layers
  7. Chaotic Migration Guide

Subreddits:

  1. /r/emacs/
  2. /r/spacemacs/
  3. /r/evilmode/
  4. /r/orgmode/

Notes (From References)

Each note should have a #### header and be included in the TOC.

What is setq?

Set Quoted. (set (quote scroll-margin) 5) is equivalent to (setq scroll-margin 5).

Spacemacs State Color Codes

There are 10 states.

The state table is from the Spacemacs documentation.

State Default Color Description
normal orange like the =normal mode of Vim=, used to execute and combine commands
insert green like the =insert mode of Vim=, used to actually insert text
visual gray like the =visual mode of Vim=, used to make text selection
motion purple exclusive to =Evil=, used to navigate read only buffers
emacs blue exclusive to =Evil=, using this state is like using a regular Emacs without Vim
replace chocolate exclusive to =Evil=, overwrites the character under point instead of inserting a new one
hybrid blue exclusive to Spacemacs, this is like the insert state except that all the emacs key bindings are available
evilified light brown exclusive to Spacemacs, this is an =emacs state= modified to bring Vim navigation, selection and search.
lisp pink exclusive to Spacemacs, used to navigate Lisp code and modify it (more [[#editing-lisp-code][info]])
iedit red exclusive to Spacemacs, used to navigate between multiple regions of text using =iedit= (more [[#replacing-text-with-iedit][info]])
iedit-insert red exclusive to Spacemacs, used to replace multiple regions of text using =iedit= (more [[#replacing-text-with-iedit][info]])

Spacemacs Fixes

Things I think need fixed.

Identified as needs fixed for spacemacs

  1. Make default colors the same as default terminal colors...
  2. not sure how to let these pass through, spacemacs has magic colors
  3. Consider moving my hotkeys to a helm menu or something, with a space leader instead of C- pattern. Also includes vim functions.
  4. Rewrite vim functions for spacemacs
  5. Consider alias for bash for spacemacs nongui as default emacs -nw
  6. Also, consider installing the emacs-plus package from homebrew cask on mac
  7. The emacs-plus package is apparently the recommended package by spacemacs, no idea why
  8. Store undo history between sessions for all edited files.
  9. manage branching undo history better? may just need training...
  10. C-c should exit insert mode
  11. Fix ridiculous html indentation
  12. Disable the mouse... try the (disable-mouse) package?

Needs Deeper Research

  1. tabs->spaces
  2. looks like highlight and <|> indent by 4 spaces in html extension files... not sure how it varies by file extension
  3. we want this to be 2 spaces by default and 4 spaces in the .py file extension
  4. indentation with the tab also does not always work, it seems to try to force a style from somewhere, tab does not always have an effect

  5. html specific

    • tab seems to add spaces when it allows input... this should not follow complex rules, tab should just put 2 spaces in regardless
    • in html when exiting insert mode, it seems to do some postprocessing on my editing, visual mode gets weird
    • things in html mode are generally not working, especially with regards to and similar
  6. Esc (1/2 second pause or less) followed by a key is a meta-key leader... need it to be dead key from now on

  7. this is related: https://github.com/syl20bnr/spacemacs/issues/2756
  8. this seems to have abated, i think i toggled a mode
  9. i do not know why it would have abated but i did restart my computer
  10. still reloading emacs settings should be enough, mysterious

  11. How do I drill down to my packages? How do I learn about my evil mode configuration and contribute to the evil mode emacs plugin?

  12. i have been reading the elisp in the .spacemacs.d layers

  13. How do I manage undo branches?

Done

  1. line numbers on startup, line number toggle?
  2. note taken - How do i search for tabs, e.g. \t
  3. scroll-margin set to 5
  4. C-l should redraw the screen - redraw does not clear search highlighting in emacs...
  5. Clear a search with SPC s c
  6. Turn off auto add closing quotes, braces, brackets, tildes, etc.
  7. in init.el: put smartparens in dotspacemacs-excluded-packages

Optional

  1. redraw screen with some key combo? - https://www.gnu.org/software/emacs/manual/html_node/elisp/Refresh-Screen.html
  2. May already be in spacemacs, check around

Greg's elisp notes

I'm starting by reading An Introduction to Programming in Emacs Lisp.

To get to this, open emacs with no arguments, hit ctrl-h i .

C-h is for help. i is for the info reader, which lets you browse manuals.

Then you're presented with a long menu.

Hit m for menu, then type Emacs Lisp Intro into the mini buffer. Then hit enter.

That gets you to the elisp intro.

Lisp stands for LISt Processing.

A list:

'(rose
  violet
  daisy
  buttercup)

Awesome and beautiful quote from the book: "The elements of this list are the names of the four different flowers, separated from each other by whitespace and surrounded by parentheses, like flowers in a field with a stone wall around them."

Text between double quotation marks is also an atom.

If there is no apostraphe before a preceding list then the first item of the list is a function. If there is an apostophe then the list is just taken as is.

Why I switched to Spacemacs

I wrote these out for someone. I prefer to see spacemacs as a vim featureset expansion.

  1. Vimscript sucks and vim isn't really great wrt extendability, extensions are all over the place.
  2. I like scheme/lisp and am writing a lot of C this year, emacs seems much better suited for working in both.
  3. Spacemacs provides most common keys in vim (but not all!).
    • For example C-a in vim is SPC n + in spacemacs. It drops chording, a net positive.
  4. Vim promises leader keys but you effectively chord enough of your actions that it's a fake claim. Spacemacs uses a space leader for most things.
  5. Vim feels stagnant, even if it isn't.
  6. The core featureset of vim doesn't really need vim the application anymore