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