SPC q q- quitSPC w /- split window verticallySPC w- - split window horizontallySPC 1- switch to window 1SPC 2- switch to window 2SPC w c- 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 norSPC l w l- switch to next workspaceSPC l w NorSPC l w porSPC 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 bopen a magit blameSPC g Bquit magit blameSPC g ccommit changesSPC g Ccheckout branchesSPC g dshow diff promptSPC g Dshow diff against current headSPC g eshow ediff comparisonSPC g Eshow ediff against current headSPC g fshow fetch promptSPC g Fshow pull promptSPC g H cclear highlightsSPC g H hhighlight regions by age of commitsSPC g H thighlight regions by last updated timeSPC g igit init a given directorySPC g Iopen helm-gitignoreSPC g lopen a magit logSPC g Ldisplay the log for a fileSPC g Pshow push promptSPC g sopen a magit status windowSPC g Sstage current fileSPC g mdisplay the last commit message of the current lineSPC g tlaunch the git time machineSPC g Uunstage 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.
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:
/evil-search$open command output bufferc copen a commit message bufferb bcheckout a branchb ccreate a branchf ffetch changesF (r) upull tracked branch and rebasegrrefreshjgoto next magit sectionC-jnext visual linekgoto previous magit sectionC-kprevious visual linel lopen log buffernnext search occurrenceNprevious search occurrenceorevert item at pointP upush to tracked branchP mpush to matching branch (e.g., upstream/develop to origin/develop)qquitson a file or hunk in a diff: stage the file or hunkxdiscard changes+on a hunk: increase hunk size-on a hunk: decrease hunk sizeSstage allTABon a file: expand/collapse diffuon a staged file: unstageUunstage all staged filesvorVselect multiple linesz zstash changes
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).
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
hgo leftjgo downkgo uplgo right
Key Binding Description
corppickeeditffixupjgo downgjmove line downkgo upgkmove line updorxkill linerrewordssquashuundoyinsert!execute
Amend a commit:
l lto open log bufferc aon the commit you want to amend,corC-c C-cto submit the changes
Squash last commit:
l lto open log bufferr eon the second to last commit, it opens the rebase bufferjto put point on last commitsto squash it,corC-c C-cto continue to the commit message buffer,corC-c C-cagain 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 Pfor 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):
Mto open the remote popupato 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 Fand choose upstream or the name you gave to itP Pto push the commit to origin
magit-gitflow provides git-flow commands in its own magit menu.
Key Binding Description:
%open magit-gitflow menu
git-timemachine allows to quickly browse the commits of the current buffer.
Key Binding Description:
SPC g tstart git timemachine and initiate micro-statecshow current commitnshow next commitNshow previous commitpshow previous commitqleave micro-state and git timemachineYcopy 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...- etcdaw- delete word under cursorcaw- delete word under cursor and put in insert modep- 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