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 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.
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 s
open magit for a git repo
$
open command output bufferc c
open a commit message bufferb b
checkout a branchb c
create a branchf f
fetch changesF u
pull tracked branch-r
toggle rebase on pullgr
refreshC-j
goto next magit sectionC-k
goto previous magit sectionl l
open log buffero
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 hunkS
stage allx
discard changes+
on a hunk: increase hunk size-
on a hunk: decrease hunk sizeTAB
on a file: expand/collapse diffu
on a staged file: unstageU
unstage all staged filesv or V
select multiple linesz z
stash 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
.
c
orp
picke
editf
fixupj
go downgj
move line downk
go upgk
move line upd
orx
kill liner
rewords
squashu
undoy
insert!
execute
Amend a commit:
l l
to open log bufferc a
on the commit you want to amend
Squash last commit:
l l
to open log bufferr e
on the second to last commit, it opens the rebase bufferj
to put point on last commits
to 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 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
open the remote popupa
add a remote
Pull changes from upstream (the parent repository you have forked) and push:
F (-r) C-u F
then choose upstream or the name you gave to it(-r)
toggle on rebase if neededP P
push 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.
c
show current commitn
show next commitN
show previous commitp
show previous commitq
leave micro-state and git timemachineY
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