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