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