SPC q q
- quitSPC w /
- split window verticallySPC w
- - split window horizontallySPC 1
- switch to window 1SPC 2
- switch to window 2SPC w d
- delete current windowSPC TAB
- switch to previous bufferSPC b b
- switch buffersSPC f f
- find a fileSPC f s
- save a file (:w also works)SPC p p
- open projectSPC p h
- find a file in current projectSPC b d
- kill current bufferSPC b M
- move buffer to another windowSPC v
- enter expand-region modeSPC b b
- Helm mini; lists buffers & recent filesCTRL SPC
- Mark ItemsCTRL z
- Actions
SPC b B
- ibufferSPC f f
- open filesCTRL h
- up a folderCTRL l
- open a folderCTRL j
- upCTRL k
- down
SPC p f
- opens root of projectSPC p p
- opens projectsSPC /
- searches through projectSPC s s
- search in a fileSPC s l
- find all function definitons in a fileSPC v
- expand regionSPC V
- contract regions (
- put parens around a regionSPC s e
- multiple cursorsn
- jumpN
- jump
SPC h d
- help describeSPC h d f
- help describe functionsSPC h d v
- help describe variablesSPC f e h
- helpALT /
- snippet completionSPC t s
- syntax checkingSPC e
- syntax checking optionsSPC a r
- rangerSPC a d
- deer
[e
- Move line up]e
- Move line down[SPACE
- Insert space above]SPACE
- Insert space below[p
- Paste above current line]p
- Paste below current line
grm
- make-all-cursorsgru
- undo-all-cursorsgrs
- pause-cursorsgrr
- resume-cursorsgrf
- make-and-goto-first-cursorgrl
- make-and-goto-last-cursorgrh
- make-cursor-hereM-n
- make-and-goto-next-cursorgrN
- skip-and-goto-next-cursorM-p
- make-and-goto-prev-cursorgrP
- skip-and-goto-prev-cursorC-n
- make-and-goto-next-matchgrn
- skip-and-goto-next-matchC-t
- skip-and-goto-next-matchC-p
- make-and-goto-prev-matchgrp
- skip-and-goto-prev-match
gt
- go to next workspacegT
- go to previous workspaceSPC l w n
- create or switch to workspace nSPC l w TAB
- switch to last active workspaceSPC l w c
- close current workspaceSPC l w n
orSPC l w l
- switch to next workspaceSPC l w N
orSPC l w p
orSPC l w h
- switch to previous workspaceSPC l w r
- set a tag to the current workspaceSPC l w w
- switched to tagged workspace
Alt %
- query-replace; active region, or cursor point to end interactive find/replacey
- do the replacement.n
- skip!
- do this and all remaining replacements without asking.Ctrl+g
- cancel.
SPC g b
- open a magit blameSPC g B
- quit magit blameSPC g c
- commit changesSPC g C
- checkout branchesSPC g d
- show diff promptSPC g D
- show diff against current headSPC g e
- show ediff comparisonSPC g E
- show ediff against current headSPC g f
- show fetch promptSPC g F
- show pull promptSPC g H c
- clear highlightsSPC g H h
- highlight regions by age of commitsSPC g H t
- highlight regions by last updated timeSPC g i
- git init a given directorySPC g I
- open helm-gitignoreSPC g l
- open a magit logSPC g L
- display the log for a fileSPC g P
- show push promptSPC g s
- open a magit status windowSPC g S
- stage current fileSPC g m
- display the last commit message of the current lineSPC g t
- launch the git time machineSPC g U
- unstage current file
Highlight by age of commit or last update time is provided by smeargle. Git time machine is provided by git-timemachine. Git last commit message per line is provided by git-messenger.
3.1 Magit
Spacemacs uses magit to manage Git repositories.
To open a status buffer, type in a buffer of a Git repository: SPC g s
Spacemacs uses evil-magit for key bindings in magit buffers (unless your editing style is set to emacs, in which case you get the default magit bindings), which are the standard magit key bindings with some minimal changes to make them comfortable for evil users.
Here are the often used bindings inside a status buffer:
Key Binding Description
/
- evil-search$
- open command output bufferc c
- open a commit message bufferb b
- checkout a branchb c
- create a branchf f
- fetch changesF (r) u
- pull tracked branch and rebasegr
- refreshj
- goto next magit sectionC-j
- next visual linek
- goto previous magit sectionC-k
- previous visual linel l
- open log buffern
- next search occurrenceN
- previous search occurrenceo
- revert item at pointP u
- push to tracked branchP m
- push to matching branch (e.g., upstream/develop to origin/develop)q
- quits
- on a file or hunk in a diff: stage the file or hunkx
- discard changes+
- on a hunk: increase hunk size-
- on a hunk: decrease hunk sizeS
- stage allTAB
- on a file: expand/collapse diffu
- on a staged file: unstageU
- unstage all staged filesv or V
- select multiple linesz z
- stash changes 3.2 Staging lines
Magit allows you to stage specific lines by selecting them in a diff and hitting s to stage. Due to inconsistencies between Vim and Emacs editing styles, if you enter visual line state with V, you will stage one more line than intended. To work around this, you can use v instead (since Magit only stages whole lines, in any case).
3.3 Commit message editing buffer
In a commit message buffer press ,c (if dotspacemacs-major-mode-leader-key is ,) or C-c C-c to commit the changes with the entered message. Pressing ,a or C-c C-k will discard the commit message.
Key Binding Description h go left j go down k go up l go right 3.4 Interactive rebase buffer
Key Binding Description c or p pick e edit f fixup j go down gj move line down k go up gk move line up d or x kill line r reword s squash u undo y insert ! execute 3.5 Quick guide for recurring use cases in Magit
Amend a commit:
l l to open log buffer
c a on the commit you want to amend
,c or C-c C-c to submit the changes
Squash last commit:
l l to open log buffer
r e on the second to last commit, it opens the rebase buffer
j to put point on last commit
s to squash it
,c or C-c C-c to continue to the commit message buffer
,c or C-c C-c again when you have finished to edit the commit message
Force push a squashed commit:
in the status buffer you should see the new commit unpushed and the old commit unpulled
P -f P for force a push (beware usually it is not recommended to rewrite the history of a public repository, but if you are sure that you are the only one to work on a repository it is ok - i.e. in your fork).
Add upstream remote (the parent repository you have forked):
M to open the remote popup
a to add a remote, type the name (i.e. upstream) and the URL
Pull changes from upstream (the parent repository you have forked) and push:
F -r C-u F and choose upstream or the name you gave to it
P P to push the commit to origin
3.6 Git-Flow
magit-gitflow provides git-flow commands in its own magit menu.
Key Binding Description % open magit-gitflow menu 3.7 Git time machine
git-timemachine allows to quickly browse the commits of the current buffer.
Key Binding Description SPC g t start git timemachine and initiate micro-state c show current commit n show next commit N show previous commit p show previous commit q leave micro-state and git timemachine Y copy current commit hash
0
- beginning of line^
- beginning of non-whitespace$
- end of line9j
- move down 9 linesw
- move forward by wordb
- move backward by wordgg
- first lineG
- last lineC-u
- up half pageC-d
- down half pagef/
- move forward to first "/" charactert/
- move forward right before the first "/" character;
- repeat that command againH
- head of the screenM
- middle of the screenL
- last of the screen}
- move forward by paragraph or block{
- move backwards by paragraph or block*
- search for word under the cursorn
- search again forwardN
- search again backwards#
- search backwards for word under cursor/
- search forward?
- search backward%
- find matching brace, paren, etcma
- mark a line in a file with marker "a"- ``a` - after moving around, go back to the exact position of marker "a"
'a
- after moving around, go back to line of marker "a":marks
- view all the marks''
- go to the last place you were
x
- delete char under cursorX
- delete char before cursorA
- add to end of lineI
- insert at the beginning of the linedd
- delete lineD
- delete from cursor to end of linedi'
- delete text inside single quotesyy
- copy lineY
- copy from cursor to end of linecc
- change lineC
- change from cursor to end of linecit
- change text inside html tagci'
- change text inside single quotesci{
- change text inside curly brackets.ci...
- etcp
- paste after cursorP
- paste before cursoro
- add line belowO
- add line above.
= repeat last commentr
- replace characterR
- replace. (overwrite) (good for columns of text)J
- join line (cursor can be anywhere on line)
v
- visual char modeV
- visual line modeC-v
- block visual mode