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.
A well-featurend Spacemacs layer for managing Git repositories.
Add magit to dotspacemacs-configuration-layers in your .spacemacs file. Access it from spacemacs using SPC f e d
Magit can only work from a Git repository
SPC g sopen magit for a git repo
$open command output bufferc copen a commit message bufferb bcheckout a branchb ccreate a branchf ffetch changesF upull tracked branch-rtoggle rebase on pullgrrefreshC-jgoto next magit sectionC-kgoto previous magit sectionl lopen log bufferorevert 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 hunkSstage allxdiscard changes+on a hunk: increase hunk size-on a hunk: decrease hunk sizeTABon a file: expand/collapse diffuon a staged file: unstageUunstage all staged filesv or Vselect 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).
When done editing, commit with <leader>c (<leader> defaults to , in spacemacs) or C-c C-c.
Discard the commit with <leader>k, or C-c C-k.
corppickeeditffixupjgo downgjmove line downkgo upgkmove line updorxkill linerrewordssquashuundoyinsert!execute
Amend a commit:
l lto open log bufferc aon the commit you want to amend
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
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):Mopen the remote popupaadd a remote
Pull changes from upstream (the parent repository you have forked) and push:
F (-r) C-u Fthen choose upstream or the name you gave to it(-r)toggle on rebase if neededP Ppush the commit to origin
magit-gitflow provides git-flow commands in its own magit menu.
%open magit-gitflow menu
git-timemachine allows to quickly browse the commits of the current buffer.
cshow current commitnshow next commitNshow previous commitpshow previous commitqleave micro-state and git timemachineYcopy current commit hash
0beginning of line^beginning of non-whitespace$end of line9jmove down 9 lineswmove forward by wordbmove backward by wordggfirst lineGlast lineC-uup half pageC-ddown half pagef/move forward to first "/" charactert/move forward right before the first "/" character;repeat that command againHhead of the screenMmiddle of the screenLlast of the screen}move forward by paragraph or block{move backwards by paragraph or block*search for word under the cursornsearch again forwardNsearch again backwards#search backwards for word under cursor/search forward?search backward%find matching brace, paren, etcmamark a line in a file with marker "a"- ``a` after moving around, go back to the exact position of marker "a"
'aafter moving around, go back to line of marker "a":marksview all the marks''go to the last place you were
xdelete char under cursorXdelete char before cursorAadd to end of lineIinsert at the beginning of the linedddelete lineDdelete from cursor to end of linedi'delete text inside single quotesyycopy lineYcopy from cursor to end of lineccchange lineCchange from cursor to end of linecitchange text inside html tagci'change text inside single quotesci{change text inside curly brackets.ci...etcppaste after cursorPpaste before cursoroadd line belowOadd line above.= repeat last commentrreplace characterRreplace. (overwrite) (good for columns of text)Jjoin line (cursor can be anywhere on line)
vvisual char modeVvisual line modeC-vblock visual mode