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