]> git.lizzy.rs Git - micro.git/blob - runtime/help/keybindings.md
Merge pull request #653 from Necklaces/master
[micro.git] / runtime / help / keybindings.md
1 # Keybindings
2
3 Micro has a plethora of hotkeys that make it easy and powerful to use and all
4 hotkeys are fully customizable to your liking.
5 Custom keybindings are stored internally in micro if changed with the `>bind` command or
6 you can also be added in the file `~/.config/micro/bindings.json` as discussed below.
7 For a list of the default keybindings in the json format used by micro, please see
8 the end of this file. For a more user-friendly list with explanations of what the default
9 hotkeys are and what they do, please see `>help defaultkeys`
10
11 If `~/.config/micro/bindings.json` does not exist, you can simply create it.
12 Micro will know what to do with it.
13
14 You can use the alt keys + arrows to move word by word.
15 Ctrl left and right move the cursor to the start and end of the line, and
16 ctrl up and down move the cursor the start and end of the buffer.
17
18 You can hold shift with all of these movement actions to select while moving.
19
20 # Rebinding keys
21
22 The bindings may be rebound using the `~/.config/micro/bindings.json`
23 file. Each key is bound to an action.
24
25 For example, to bind `Ctrl-y` to undo and `Ctrl-z` to redo, you could put the
26 following in the `bindings.json` file.
27
28 ```json
29 {
30         "CtrlY": "Undo",
31         "CtrlZ": "Redo"
32 }
33 ```
34
35 In addition to editing your `~/.config/micro/bindings.json`, you can run
36 `>bind <keycombo> <action>` For a list of bindable actions, see below.
37
38 You can also chain commands when rebinding. For example, if you want Alt-s to save
39 and quit you can bind it like so:
40
41 ```json
42 {
43     "Alt-s": "Save,Quit"
44 }
45 ```
46
47 # Unbinding keys
48
49 It is also possible to disable any of the default key bindings by use of the 
50 `UnbindKey` action in the user's `bindings.json` file.
51
52 # Bindable actions and bindable keys
53
54 The list of default keybindings contains most of the possible actions and keys
55 which you can use, but not all of them. Here is a full list of both.
56
57 Full list of possible actions:
58
59 ```
60 CursorUp
61 CursorDown
62 CursorPageUp
63 CursorPageDown
64 CursorLeft
65 CursorRight
66 CursorStart
67 CursorEnd
68 SelectToStart
69 SelectToEnd
70 SelectUp
71 SelectDown
72 SelectLeft
73 SelectRight
74 WordRight
75 WordLeft
76 SelectWordRight
77 SelectWordLeft
78 MoveLinesUp
79 MoveLinesDown
80 DeleteWordRight
81 DeleteWordLeft
82 SelectToStartOfLine
83 SelectToEndOfLine
84 InsertNewline
85 InsertSpace
86 Backspace
87 Delete
88 Center
89 InsertTab
90 Save
91 SaveAll
92 SaveAs
93 Find
94 FindNext
95 FindPrevious
96 Undo
97 Redo
98 Copy
99 Cut
100 CutLine
101 DuplicateLine
102 DeleteLine
103 IndentSelection
104 OutdentSelection
105 Paste
106 SelectAll
107 OpenFile
108 Start
109 End
110 PageUp
111 PageDown
112 HalfPageUp
113 HalfPageDown
114 StartOfLine
115 EndOfLine
116 ToggleHelp
117 ToggleRuler
118 JumpLine
119 ClearStatus
120 ShellMode
121 CommandMode
122 Quit
123 QuitAll
124 AddTab
125 PreviousTab
126 NextTab
127 NextSplit
128 Unsplit
129 VSplit
130 HSplit
131 PreviousSplit
132 ToggleMacro
133 PlayMacro
134 UnbindKey
135 ```
136
137 Here is the list of all possible keys you can bind:
138
139 ```
140 Up
141 Down
142 Right
143 Left
144 UpLeft
145 UpRight
146 DownLeft
147 DownRight
148 Center
149 PageUp
150 PageDown
151 Home
152 End
153 Insert
154 Delete
155 Help
156 Exit
157 Clear
158 Cancel
159 Print
160 Pause
161 Backtab
162 F1
163 F2
164 F3
165 F4
166 F5
167 F6
168 F7
169 F8
170 F9
171 F10
172 F11
173 F12
174 F13
175 F14
176 F15
177 F16
178 F17
179 F18
180 F19
181 F20
182 F21
183 F22
184 F23
185 F24
186 F25
187 F26
188 F27
189 F28
190 F29
191 F30
192 F31
193 F32
194 F33
195 F34
196 F35
197 F36
198 F37
199 F38
200 F39
201 F40
202 F41
203 F42
204 F43
205 F44
206 F45
207 F46
208 F47
209 F48
210 F49
211 F50
212 F51
213 F52
214 F53
215 F54
216 F55
217 F56
218 F57
219 F58
220 F59
221 F60
222 F61
223 F62
224 F63
225 F64
226 CtrlSpace
227 CtrlA
228 CtrlB
229 CtrlC
230 CtrlD
231 CtrlE
232 CtrlF
233 CtrlG
234 CtrlH
235 CtrlI
236 CtrlJ
237 CtrlK
238 CtrlL
239 CtrlM
240 CtrlN
241 CtrlO
242 CtrlP
243 CtrlQ
244 CtrlR
245 CtrlS
246 CtrlT
247 CtrlU
248 CtrlV
249 CtrlW
250 CtrlX
251 CtrlY
252 CtrlZ
253 CtrlLeftSq
254 CtrlBackslash
255 CtrlRightSq
256 CtrlCarat
257 CtrlUnderscore
258 Backspace
259 Tab
260 Esc
261 Escape
262 Enter
263 ```
264
265 # Default keybinding configuration.
266
267 ```json
268 {
269     "Up":             "CursorUp",
270     "Down":           "CursorDown",
271     "Right":          "CursorRight",
272     "Left":           "CursorLeft",
273     "ShiftUp":        "SelectUp",
274     "ShiftDown":      "SelectDown",
275     "ShiftLeft":      "SelectLeft",
276     "ShiftRight":     "SelectRight",
277     "AltLeft":        "WordLeft",
278     "AltRight":       "WordRight",
279     "AltShiftRight":  "SelectWordRight",
280     "AltShiftLeft":   "SelectWordLeft",
281     "AltUp":          "MoveLinesUp",
282     "AltDown":        "MoveLinesDown",
283     "CtrlLeft":       "StartOfLine",
284     "CtrlRight":      "EndOfLine",
285     "CtrlShiftLeft":  "SelectToStartOfLine",
286     "ShiftHome":      "SelectToStartOfLine",
287     "CtrlShiftRight": "SelectToEndOfLine",
288     "ShiftEnd":       "SelectToEndOfLine",
289     "CtrlUp":         "CursorStart",
290     "CtrlDown":       "CursorEnd",
291     "CtrlShiftUp":    "SelectToStart",
292     "CtrlShiftDown":  "SelectToEnd",
293     "Enter":          "InsertNewline",
294     "Space":          "InsertSpace",
295     "CtrlH":          "Backspace",
296     "Backspace":      "Backspace",
297     "Alt-CtrlH":      "DeleteWordLeft",
298     "Alt-Backspace":  "DeleteWordLeft",
299     "Tab":            "IndentSelection,InsertTab",
300     "Backtab":        "OutdentSelection",
301     "CtrlO":          "OpenFile",
302     "CtrlS":          "Save",
303     "CtrlF":          "Find",
304     "CtrlN":          "FindNext",
305     "CtrlP":          "FindPrevious",
306     "CtrlZ":          "Undo",
307     "CtrlY":          "Redo",
308     "CtrlC":          "Copy",
309     "CtrlX":          "Cut",
310     "CtrlK":          "CutLine",
311     "CtrlD":          "DuplicateLine",
312     "CtrlV":          "Paste",
313     "CtrlA":          "SelectAll",
314     "CtrlT":          "AddTab",
315     "Alt,":           "PreviousTab",
316     "Alt.":           "NextTab",
317     "Home":           "StartOfLine",
318     "End":            "EndOfLine",
319     "CtrlHome":       "CursorStart",
320     "CtrlEnd":        "CursorEnd",
321     "PageUp":         "CursorPageUp",
322     "PageDown":       "CursorPageDown",
323     "CtrlG":          "ToggleHelp",
324     "CtrlR":          "ToggleRuler",
325     "CtrlL":          "JumpLine",
326     "Delete":         "Delete",
327     "CtrlB":          "ShellMode",
328     "CtrlQ":          "Quit",
329     "CtrlE":          "CommandMode",
330     "CtrlW":          "NextSplit",
331     "CtrlU":          "ToggleMacro",
332     "CtrlJ":          "PlayMacro",
333
334     // Emacs-style keybindings
335     "Alt-f": "WordRight",
336     "Alt-b": "WordLeft",
337     "Alt-a": "StartOfLine",
338     "Alt-e": "EndOfLine",
339     "Alt-p": "CursorUp",
340     "Alt-n": "CursorDown",
341
342     // Integration with file managers
343     "F1":  "ToggleHelp",
344     "F2":  "Save",
345     "F3":  "Find",
346     "F4":  "Quit",
347     "F7":  "Find",
348     "F10": "Quit",
349     "Esc": "Escape",
350 }
351 ```
352
353 #Final notes
354 Note: On some old terminal emulators and on Windows machines, `CtrlH` should be used
355 for backspace.
356
357 Additionally, alt keys can be bound by using `Alt-key`. For example `Alt-a`
358 or `Alt-Up`. Micro supports an optional `-` between modifiers like `Alt` and `Ctrl`
359 so `Alt-a` could be rewritten as `Alta` (case matters for alt bindings). This is
360 why in the default keybindings you can see `AltShiftLeft` instead of `Alt-ShiftLeft` 
361 (they are equivalent).