I’m learning Spacemacs (with Vim key bindings (check out this blog post by Stéphane Caron)) and would like to share some of my notes here.
For detailed instructions and a deeper understanding please refer to Spacemacs’ official documentation.

various editing modes

ESC Key returns you from other modes to the normal mode.

You can learn Vim key bindings with (SPACE h T v), the Emacs Evil Tutor :-p.
Of course there are many other wonderful and interactive tutorials out there…


Vim basic navigation

word-level

  • w forward motion by word
  • b backward motion by word
  • e forward motion by end of word

line-level

  • 0 the beginning of line
  • $ end of line
  • ^ first non-empty character of the line

buffer-level

  • (Ctrl U) scrolls up
  • (Ctrl D) scrolls down
  • gg beginning of buffer
  • G end of buffer

moving the cursor

  • H to the highest line of the screen
  • M to the middle line of the screen
  • L to the lowest line of the screen

find f|F

  • f find in forward direction
  • F find in backward direction
1
2
3
4
fo 
>>> Cursor jumps to the next first occurrence of the letter "o".
Fo
>>> Cursor jumps to the last immediate occurrence of the letter "o".

to t|T (a variant of find)

a simple example


Editing Commands

Open

  • o opens a line below and enters INSERT mode.
  • O opens a line above and enters INSERT mode.

Delete

Deletion combines with movement commands.

  • dw deletes a word
  • de deletes from cursor position to end of the word
  • dd deletes the line
  • x deletes a single character at cursor position (like on a typewriter!)

Change

Change combines with movement commands. Think of it as delete and enter into INSERT mode.

  • cw changes the word, i.e. deletes the word and puts you in INSERT mode.
  • ce deletes the word from cursor position to end of the word and enters INSERT mode.
  • cc deletes the line and enters INSERT mode.

Replace

  • r replaces single character at cursor position, after replacement in NORMAL mode.
  • R enters and remains in REPLACE mode until you switch mode.

Undo and Redo

  • u to undo changes.
  • Ctrl r to redo.

Copy and Paste

y for Yank and p for Paste

These two also combines with movement commands.

  • yy copies current line.
  • yw copies the word.
  • p pastes at cursor position.

If you want to move a line, you can use dd to delete the line and then p to paste it wherever you want.

--VISUAL-- for text selection

To select blocks of text we use VISUAL mode and navigate to make a selection.
Then we can use y for copying the selection and automatically returns to NORMAL mode.

  • --VISUAL LINE-- selects by lines
  • --VISUAL BLOCK-- selects by rectangular blocks of text
1
`~` flips the case of selected text.

Counts

We can use numbers for quick and specific movements.
For instance, <number>j = pressing j <number> times.
Therefore:

  • 4k moves cursor up 4 lines
  • v3e enters VISUAL mode, select 3 words (select to the end of the third word).
  • d7w or 7dw deletes 7 words counting from the word the cursor is at.

Since counts are so useful, there’s a trick that facilitates the use of line numbers. Instead of counting or mentally subtracting line numbers, we can use relative line numbers!

Relative Line Numbers

highly recommended

Setting up relative line numbers

In .spacemacs, set dotspacemacs-line-numbers 'relative.


Modifiers

a for Around and i for Inside

  • ci[ changes (deletes) everything inside square brackets, enter INSERT mode.
  • di( deletes everything inside parentheses, remains in NORMAL mode.
  • da( deletes also the parentheses around, remains in NORMAL mode.

Miscellaneous

Matching Parenthesis

If you have your cursor on one of them, % will show you its match.

Case Flip

~ flips the case of selected text.

The lazy dot .

. simply repeats the previous editing command that Vim made.


The dotspacemacs file

.spacemacs is Spacemacs’ configuration file.
The dotfile is written in emacs-lisp language, ;; is used for comments.

Most used commands related to the dotfile:

  • (SPACE f e) shortcut combo opens a list of commands.
    • d -> opens the dotfile
    • R -> reloads configuration

Usually the most important section of the dotfile is under dotspacemacs-configuration-layers.


Spacemacs GUI - Spaceline

Spaceline is spacemacs’ powerline.

spaceline

The number displayed on the left corner is the window number.
Other information on the line:

  • status of the file
    • * shows that the file has been modified but the changes are not saved.
  • size of the file
  • filename
  • the current major mode
    • Emacs-Lisp, Org, Markdown etc.
      • In Emacs-Lisp major mode, use (SPACE c L) to toggle comments.
  • On the right of the powerline: cursor position
    • <line>:<character> <percentage through the file>

Under the spaceline there’s usually an indication of the current editing mode, in the above example it is the INSERT mode.


Bits and pieces

Save Buffer

Using the familiar commandline mode (led by the : key):

  • :w writes buffer to file.
  • :q! quits without saving any changes.
    • :q quits (current window).
    • :qa quits all windows.

A more Spacemacs-way of saving the buffer is (SPACE f s).

Font

Setting default font and font size

  1. Search through the dotfile using vim syntax: /font.
  2. Modify dotspacemacs-default-font.
  3. Save the dotfile and restart emacs.

Zoom-in and -out

(SPACE z f) enters zoom frame transient state. Type q to quit.

Toggle line wrap

(SPACE t l) toggles line wrap.