Advertisement
Guest User

Untitled

a guest
Feb 21st, 2019
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.42 KB | None | 0 0
  1. ## Useful Spacemacs commands
  2.  
  3. - `SPC q q` - quit
  4. - `SPC w /` - split window vertically
  5. - `SPC w` - - split window horizontally
  6. - `SPC 1` - switch to window 1
  7. - `SPC 2` - switch to window 2
  8. - `SPC w c` - delete current window
  9. - `SPC TAB` - switch to previous buffer
  10. - `SPC b b` - switch buffers
  11. - `SPC f f` - find a file
  12. - `SPC f s` - save a file (:w also works)
  13. - `SPC p p` - open project
  14. - `SPC p h` - find a file in current project
  15. - `SPC b d` - kill current buffer
  16. - `SPC b M` - move buffer to another window
  17. - `SPC v` - enter expand-region mode
  18. - `SPC b b` - Helm mini; lists buffers & recent files
  19. - `CTRL SPC` - Mark Items
  20. - `CTRL z` - Actions
  21. - `SPC b B` - ibuffer
  22. - `SPC f f` - open files
  23. - `CTRL h` - up a folder
  24. - `CTRL l` - open a folder
  25. - `CTRL j` - up
  26. - `CTRL k` - down
  27. - `SPC p f` - opens root of project
  28. - `SPC p p` - opens projects
  29. - `SPC /` - searches through project
  30. - `SPC s s` - search in a file
  31. - `SPC s l` - find all function definitons in a file
  32. - `SPC v` - expand region
  33. - `SPC V` - contract region
  34. - `s (` - put parens around a region
  35. - `SPC s e` - multiple cursors
  36. - `n` - jump
  37. - `N` - jump
  38. - `SPC h d` - help describe
  39. - `SPC h d f` - help describe functions
  40. - `SPC h d v` - help describe variables
  41. - `SPC f e h` - help
  42. - `ALT /` - snippet completion
  43. - `SPC t s` - syntax checking
  44. - `SPC e` - syntax checking options
  45. - `SPC a r` - ranger
  46. - `SPC a d` - deer
  47.  
  48. ## unimpaired
  49.  
  50. - `[e` - Move line up
  51. - `]e` - Move line down
  52. - `[SPACE` - Insert space above
  53. - `]SPACE` - Insert space below
  54. - `[p` - Paste above current line
  55. - `]p` - Paste below current line
  56.  
  57. ## evil-mc
  58.  
  59. - `grm` - make-all-cursors
  60. - `gru` - undo-all-cursors
  61. - `grs` - pause-cursors
  62. - `grr` - resume-cursors
  63. - `grf` - make-and-goto-first-cursor
  64. - `grl` - make-and-goto-last-cursor
  65. - `grh` - make-cursor-here
  66. - `M-n` - make-and-goto-next-cursor
  67. - `grN` - skip-and-goto-next-cursor
  68. - `M-p` - make-and-goto-prev-cursor
  69. - `grP` - skip-and-goto-prev-cursor
  70. - `C-n` - make-and-goto-next-match
  71. - `grn` - skip-and-goto-next-match
  72. - `C-t` - skip-and-goto-next-match
  73. - `C-p` - make-and-goto-prev-match
  74. - `grp` - skip-and-goto-prev-match
  75.  
  76. ## Eyebrowse
  77.  
  78. - `gt` - go to next workspace
  79. - `gT` - go to previous workspace
  80. - `SPC l w n` - create or switch to workspace n
  81. - `SPC l w TAB` - switch to last active workspace
  82. - `SPC l w c` - close current workspace
  83. - `SPC l w n` or `SPC l w l` - switch to next workspace
  84. - `SPC l w N` or `SPC l w p` or `SPC l w h` - switch to previous workspace
  85. - `SPC l w r` - set a tag to the current workspace
  86. - `SPC l w w` - switched to tagged workspace
  87.  
  88. ## Find/Replace
  89.  
  90. - `Alt %` - query-replace; active region, or cursor point to end interactive find/replace
  91. - `y` - do the replacement.
  92. - `n` - skip
  93. - `!` - do this and all remaining replacements without asking.
  94. - `Ctrl+g` - cancel.
  95.  
  96. ## Git
  97.  
  98. - `SPC g b` - open a magit blame
  99. - `SPC g B` - quit magit blame
  100. - `SPC g c` - commit changes
  101. - `SPC g C` - checkout branches
  102. - `SPC g d` - show diff prompt
  103. - `SPC g D` - show diff against current head
  104. - `SPC g e` - show ediff comparison
  105. - `SPC g E` - show ediff against current head
  106. - `SPC g f` - show fetch prompt
  107. - `SPC g F` - show pull prompt
  108. - `SPC g H c` - clear highlights
  109. - `SPC g H h` - highlight regions by age of commits
  110. - `SPC g H t` - highlight regions by last updated time
  111. - `SPC g i` - git init a given directory
  112. - `SPC g I` - open helm-gitignore
  113. - `SPC g l` - open a magit log
  114. - `SPC g L` - display the log for a file
  115. - `SPC g P` - show push prompt
  116. - `SPC g s` - open a magit status window
  117. - `SPC g S` - stage current file
  118. - `SPC g m` - display the last commit message of the current line
  119. - `SPC g t` - launch the git time machine
  120. - `SPC g U` - unstage current file
  121.  
  122. Highlight by age of commit or last update time is provided by smeargle.
  123. Git time machine is provided by git-timemachine.
  124. Git last commit message per line is provided by git-messenger.
  125.  
  126.  
  127. 3.1 Magit
  128.  
  129. Spacemacs uses magit to manage Git repositories.
  130.  
  131. To open a status buffer, type in a buffer of a Git repository: SPC g s
  132.  
  133. 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.
  134.  
  135. Here are the often used bindings inside a status buffer:
  136.  
  137. Key Binding Description
  138.  
  139. - / evil-search
  140. - $ open command output buffer
  141. - c c open a commit message buffer
  142. - b b checkout a branch
  143. - b c create a branch
  144. - f f fetch changes
  145. - F (r) u pull tracked branch and rebase
  146. - gr refresh
  147. - j goto next magit section
  148. - C-j next visual line
  149. - k goto previous magit section
  150. - C-k previous visual line
  151. - l l open log buffer
  152. - n next search occurrence
  153. - N previous search occurrence
  154. - o revert item at point
  155. - P u push to tracked branch
  156. - P m push to matching branch (e.g., upstream/develop to origin/develop)
  157. - q quit
  158. - s on a file or hunk in a diff: stage the file or hunk
  159. - x discard changes
  160. - + on a hunk: increase hunk size
  161. - - on a hunk: decrease hunk size
  162. - S stage all
  163. - TAB on a file: expand/collapse diff
  164. - u on a staged file: unstage
  165. - U unstage all staged files
  166. - v or V select multiple lines
  167. - z z stash changes
  168.  
  169.  
  170. 3.2 Staging lines
  171.  
  172. 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).
  173.  
  174. 3.3 Commit message editing buffer
  175.  
  176. 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.
  177.  
  178. Key Binding Description
  179.  
  180. - h go left
  181. - j go down
  182. - k go up
  183. - l go right
  184.  
  185. 3.4 Interactive rebase buffer
  186.  
  187. Key Binding Description
  188.  
  189. - c or p pick
  190. - e edit
  191. - f fixup
  192. - j go down
  193. - gj move line down
  194. - k go up
  195. - gk move line up
  196. - d or x kill line
  197. - r reword
  198. - s squash
  199. - u undo
  200. - y insert
  201. - ! execute
  202.  
  203. 3.5 Quick guide for recurring use cases in Magit
  204.  
  205. Amend a commit:
  206.  
  207. l l to open log buffer
  208. c a on the commit you want to amend
  209. ~,c~ or C-c C-c to submit the changes
  210.  
  211. Squash last commit:
  212. l l to open log buffer
  213. r e on the second to last commit, it opens the rebase buffer
  214. j to put point on last commit
  215. s to squash it
  216. ~,c~ or C-c C-c to continue to the commit message buffer
  217. ~,c~ or C-c C-c again when you have finished to edit the commit message
  218.  
  219. Force push a squashed commit:
  220. in the status buffer you should see the new commit unpushed and the old commit unpulled
  221. 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).
  222. Add upstream remote (the parent repository you have forked):
  223. M to open the remote popup
  224. a to add a remote, type the name (i.e. upstream) and the URL
  225. Pull changes from upstream (the parent repository you have forked) and push:
  226. F -r C-u F and choose upstream or the name you gave to it
  227. P P to push the commit to origin
  228. 3.6 Git-Flow
  229.  
  230. magit-gitflow provides git-flow commands in its own magit menu.
  231.  
  232. Key Binding Description
  233. % open magit-gitflow menu
  234. 3.7 Git time machine
  235.  
  236. git-timemachine allows to quickly browse the commits of the current buffer.
  237.  
  238. Key Binding Description
  239. SPC g t start git timemachine and initiate micro-state
  240. c show current commit
  241. n show next commit
  242. N show previous commit
  243. p show previous commit
  244. q leave micro-state and git timemachine
  245. Y copy current commit hash
  246.  
  247.  
  248. ## Useful Vim key bindings
  249.  
  250. ### movement
  251.  
  252. - `0` - beginning of line
  253. - `^` - beginning of non-whitespace
  254. - `$` - end of line
  255. - `9j` - move down 9 lines
  256. - `w` - move forward by word
  257. - `b` - move backward by word
  258. - `gg` - first line
  259. - `G` - last line
  260. - `C-u` - up half page
  261. - `C-d` - down half page
  262. - `f/` - move forward to first "/" character
  263. - `t/` - move forward right before the first "/" character
  264. - `;` - repeat that command again
  265. - `H` - head of the screen
  266. - `M` - middle of the screen
  267. - `L` - last of the screen
  268. - `}` - move forward by paragraph or block
  269. - `{` - move backwards by paragraph or block
  270. - `*` - search for word under the cursor
  271. - `n` - search again forward
  272. - `N` - search again backwards
  273. - `#` - search backwards for word under cursor
  274. - `/` - search forward
  275. - `?` - search backward
  276. - `%` - find matching brace, paren, etc
  277. - `ma` - mark a line in a file with marker "a"
  278. - ``a` - after moving around, go back to the exact position of marker "a"
  279. - `'a` - after moving around, go back to line of marker "a"
  280. - `:marks` - view all the marks
  281. - `''` - go to the last place you were
  282.  
  283. ### editing
  284.  
  285. - `x` - delete char under cursor
  286. - `X` - delete char before cursor
  287. - `A` - add to end of line
  288. - `I` - insert at the beginning of the line
  289. - `dd` - delete line
  290. - `D` - delete from cursor to end of line
  291. - `di'` - delete text inside single quotes
  292. - `yy` - copy line
  293. - `Y` - copy from cursor to end of line
  294. - `cc` - change line
  295. - `C` - change from cursor to end of line
  296. - `cit` - change text inside html tag
  297. - `ci'` - change text inside single quotes
  298. - `ci{` - change text inside curly brackets.
  299. - `ci...` - etc
  300. - `p` - paste after cursor
  301. - `P` - paste before cursor
  302. - `o` - add line below
  303. - `O` - add line above
  304. - `.` = repeat last comment
  305. - `r` - replace character
  306. - `R` - replace. (overwrite) (good for columns of text)
  307. - `J` - join line (cursor can be anywhere on line)
  308.  
  309. ### visual mode
  310.  
  311. - `v` - visual char mode
  312. - `V` - visual line mode
  313. - `C-v` - block visual mode
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement