]> code.delx.au - dotemacs/blob - README_KEYBINDINGS.md
goto-chg - go to last edit
[dotemacs] / README_KEYBINDINGS.md
1 # References
2 * [Reference Card](https://www.gnu.org/software/emacs/refcards/pdf/refcard.pdf)
3 * [Key Binding Conventions](https://www.gnu.org/software/emacs/manual/html_node/elisp/Key-Binding-Conventions.html)
4
5 # General commands
6 ```
7 C-x C-c Quit Emacs
8 C-u C-x C-c Save and quit
9 C-g Cancel command
10 C-/ Undo
11 C-g C-/ Undo undo
12 C-x z Repeat last command
13 M-x Execute command
14 M-: Evaluate expression as elisp
15 M-x eval-buffer Load current buffer as elisp
16 C-x C-0 Reset font to standard
17 C-x C-+/= Increase font size
18 C-x C-- Decrease font size
19 ```
20
21 # Help
22 ```
23 C-h C-h Help
24 C-h k Help about key binding
25 C-h v Describe variable
26 C-h f Describe function
27 C-h m Documentation on active modes
28 <prefix> C-h Show bindings starting with <prefix>
29 C-c C-b Back to previous help topic (while in help-mode)
30 q Quit window and bury buffer
31 ```
32
33 # Search
34 ```
35 C-s Search forward (ivy/swiper mode)
36 C-r Resume ivy search
37 C-7 Start a cursor for each result (while searching)
38 C-' Switch to avy jump mode
39 M-q Replace searched item (while searching)
40 M-p Search for previous item (while searching)
41 M-n Search for symbol at point (while searching)
42 C-c C-o Dump all results into a buffer (ivy-occur)
43 M-. Find thing at point
44 M-, Pop tag mark
45 ```
46
47 # Files/buffers
48 ```
49 C-x C-s Save current buffer
50 C-x s Save some buffers
51 C-x C-w Write buffer to file
52 C-x C-f Find file
53 C-x C-v Find file and kill current buffer
54 C-x f Find files in git repository
55 C-x g Grep in git repository
56 M-q Replace in git repository (while in git grep)
57 M-x find-file-at-point Find (open) filename at point
58 M-x browse-url-at-point Browse URL at point
59 C-x k Kill buffer
60 C-x c Clean up all buffers that are not visible
61 C-x b Select named buffer
62 C-x C-b Show all buffers
63 C-x C-r Show recent files
64 M-x scratch-buffer Create new scratch buffer
65 //,~ Go to {root,home} directory in find-file
66 ```
67
68 # Windows/frames
69 ```
70 C-x o Switch to other window
71 C-x 0 Delete window
72 C-x 1 Switch to single window
73 C-x 2 Split vertically
74 C-x 3 Split horizontally
75 C-x 9 Resize windows with arrow keys
76 C-x { / C-x } Shrink/enlarge window horizontally
77 C-Up / C-Down / C-Left / C-Right Switch windows
78 C-l Recenter display (center, top then bottom)
79 C-M-l Reposition window to contain useful text (eg entire defun)
80 C-x 5 2 New frame (X11 window)
81 ```
82
83 # Movement
84 ```
85 M-m Jump back to start of indentation
86 M-r Jump to window top/bottom/middle
87 M-g Tab Jump to column
88 M-g f Jump to charactor, ;/, to go forward/back
89 M-g g Jump to visible line or any line
90 M-g j Jump to word by first character
91 M-g M-g Jump to visible line or any line
92 C-a Beginning of line
93 C-e End of line
94 C-p Back one line
95 C-n Forward one line
96 C-b Back one character
97 C-n Forward one character
98 M-b Back a word
99 M-f Forward a word
100 M-a Backward sentence
101 M-e Forward sentence
102 M-v Back page
103 C-v Forward page
104 M-{ Back one paragraph
105 M-} Forward one paragraph
106 M-< Top of file
107 M-> End of file
108 C-M-p Back to start of balanced expression
109 C-M-n Forward to end of balanced expression
110 C-M-b Back one s-expression / symbol
111 C-M-f Forward one s-expression / symbol
112 C-M-u Move up one level of parentheses
113 ```
114
115 # Text formatting
116 ```
117 Tab Indent current line correctly
118 C-x Tab Indent region with left/right
119 M-/ Expand at point
120 M-Tab Auto-complete at point
121 M-; Comment line or region
122 M-i Change inner region
123 M-q Reformat paragraph
124 M-l Lower case word
125 M-u Upper case word
126 M-c Capitalise word
127 C-x C-l Lower case region
128 C-x C-u Upper case region
129 C-o Insert a new line above point
130 M-o Insert a new line below point
131 C-j Newline and maybe indent
132 M-^ Join to previous line
133 M-j New line with comment
134 C-q Quoted insert
135 C-M-\ Indent region
136 C-c c Copy line
137 C-c d Duplicate line
138 M-x comment-box Wrap region in comment box
139 ```
140
141 # Marking
142 ```
143 C-Space Set mark (start selection)
144 C-Space C-Space Set mark to point
145 C-u C-space Pop mark
146 C-x C-space Pop global mark
147 C-x C-x Exchange point and mark
148 C-M-h Highlight expression
149 M-@ Set mark at end of next word
150 C-= Expand region
151 C-c l Insert extra cursor on all lines in region
152 C-c m Ask to insert extra cursor at locations matching selected region
153 M-= Display info about region
154 C-. Go to last edit
155 C-, Go to last edit reverse
156 ```
157
158 # Highlighting
159 ```
160 M-s h u Unhighlight regexp
161 M-s h . Highlight symbol at point
162 M-s h p Highlight phrase
163 M-s h r Highlight regexp
164 M-s h l Highlight lines matching regexp
165 ```
166
167 # Killing and deleting
168 ```
169 C-M-k Kill s-expression / symbol
170 C-w Kill from mark to point
171 C-y Yank text (paste)
172 M-y Scroll through kill ring (paste buffer)
173 M-z <char> Kill until <char>
174 C-k Kill to end of line
175 M-0 C-k Kill to beginning of line
176 C-c k Kill whole line
177 C-c s Copy line
178 C-d Delete next character
179 M-d Delete next word
180 M-Backspace Delete previous word
181 M-Space Collpase to one space around point
182 M-\ Delete spaces around point
183 C-x C-o Collapse blank lines
184 M-x delete-trailing-whitespace Delete trailing whitespace
185 ```
186
187 # Transposing
188 ```
189 C-t Transpose chars
190 M-t Transpose words
191 C-x C-t Transpose lines
192 C-M-t Transpose s-expressions
193 ```
194
195 # Rectangle
196 ```
197 C-x Space Toggle mark rectangle mode
198 C-x r t Replace rectangle with string
199 ```
200
201 # Macros
202 ```
203 F3 , F4 Start recording macro, finish recording macro
204 C-u F3 Play last macro then append keys
205 F4 Play back macro
206 C-x C-k b Bind macro to key (0-9, A-Z)
207 C-x C-k C-e Edit last macro
208 C-x C-k l Edit recent keys as macro
209 C-x C-k r Apply macro to region lines
210 ```
211
212 # Registers
213 ```
214 C-x r s <?> Copy region into register
215 C-x r i <?> Insert text from register
216 C-x r Space <?> Save point position to register
217 C-x r j <?> Jump to point position at register
218 ```
219
220 # Mouse secondary selection
221 ```
222 Meta-Drag Set selection
223 Meta-Right-Click Yank secondary
224 ```
225
226
227 # Mode switching
228 ```
229 C-x C-j Open direx at current file
230 F8 Toggle flyspell-mode
231 F9 Toggle whitespace mode
232 F10 Toggle word wrap
233 M-s o Search in buffer and display results in occur-mode
234 M-x multi-occur Search in buffers and display results in occur-mode
235 M-x eshell Run eshell
236 M-x ielm Run Emacs Lisp REPL
237 M-x linum-mode Display line numbers
238 M-x overwrite-mode Switch to overwrite mode
239 M-x shell Run bash shell
240 M-x slime Run Common Lisp REPL
241 M-x smerge-ediff Resolve merge conflicts in multi-window mode
242 M-x smerge-mode Resolve merge conflicts by hunks
243 M-x term Run terminal
244 M-x yas-reload-all Reload all snippets
245 ```
246
247 # Occur
248 ```
249 g Reload
250 e Switch to edit mode
251 C-c C-c Switch back to occur mode
252 M-g M-p Previous occurence
253 M-g M-n Next occurence
254 ```
255
256 # Magit / Git gutter
257 ```
258 C-c g d Popup diff
259 C-c g p Previous hunk
260 C-c g n Next hunk
261 C-c g r Revert hunk
262 C-c g s Magit status
263 C-c g f Magit file specific commands
264 C-c g g Magit dispatch popup
265 p Previous section
266 n Next section
267 M-p Previous sibling section
268 M-n Next sibling section
269 ^ Up section
270 Tab Toggle visibility of section
271 C-Tab Cycle visibility of section and its children
272 q Kill window and bury buffer
273 C-c C-c Perform action
274 C-c C-k Cancel action
275 ```
276
277 # Lisp
278 ```
279 C-M-x Eval top-level form
280 C-c C-z Switch to REPL
281 C-c C-c Compile and load the top-level form at point
282 C-c M-k Compile (but not load) the current buffer's file
283 ```
284
285
286 # Javascript
287 ```
288 C-c C-r Rename variable
289 C-c C-c Find type
290 C-c C-d Find docs
291 ```
292
293
294 # Shell
295 ```
296 M-! Execute command
297 M-& Execute command asynchronously
298 M-| Execute with region
299 C-u M-| Filter with region
300 ```
301
302 # Smerge mode
303 ```
304 C-c ^ p Go to previous hunk
305 C-c ^ n Go to next hunk
306 C-c ^ Return Keep current
307 C-c ^ a Keep all
308 C-c ^ m Keep mine
309 C-c ^ o Keep other
310 ```
311
312 # Flyspell
313 ```
314 M-$ Correct word
315 C-M-i Automatically correct word
316 C-; Automatically correct last word
317 <mouse-2> Popup word correction
318 ```
319
320 # Flycheck
321 ```
322 C-c ! v Verify setup
323 C-c ! n Next error
324 C-c ! p Previous error
325 C-c ! l List errors
326 C-c ! x Disable checker
327 ```