| 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 |
|
| 6 |
Custom keybindings are stored internally in micro if changed with the `> bind` |
| 7 |
command or can also be added in the file `~/.config/micro/bindings.json` as |
| 8 |
discussed below. For a list of the default keybindings in the json format used |
| 9 |
by micro, please see the end of this file. For a more user-friendly list with |
| 10 |
explanations of what the default hotkeys are and what they do, please see |
| 11 |
`> help defaultkeys` (a json formatted list of default keys is included |
| 12 |
at the end of this document). |
| 13 |
|
| 14 |
If `~/.config/micro/bindings.json` does not exist, you can simply create it. |
| 15 |
Micro will know what to do with it. |
| 16 |
|
| 17 |
You can use Ctrl + arrows to move word by word (Alt + arrows for Mac). Alt + left and right |
| 18 |
move the cursor to the start and end of the line (Ctrl + left/right for Mac), and Ctrl + up and down move the |
| 19 |
cursor to the start and end of the buffer. |
| 20 |
|
| 21 |
You can hold shift with all of these movement actions to select while moving. |
| 22 |
|
| 23 |
## Rebinding keys |
| 24 |
|
| 25 |
The bindings may be rebound using the `~/.config/micro/bindings.json` file. |
| 26 |
Each key is bound to an action. |
| 27 |
|
| 28 |
For example, to bind `Ctrl-y` to undo and `Ctrl-z` to redo, you could put the |
| 29 |
following in the `bindings.json` file. |
| 30 |
|
| 31 |
```json |
| 32 |
{ |
| 33 |
"Ctrl-y": "Undo", |
| 34 |
"Ctrl-z": "Redo" |
| 35 |
} |
| 36 |
``` |
| 37 |
|
| 38 |
**Note:** The syntax `<Modifier><key>` is equivalent to `<Modifier>-<key>`. In |
| 39 |
addition, `Ctrl-Shift` bindings are not supported by terminals, and are the same |
| 40 |
as simply `Ctrl` bindings. This means that `CtrlG`, `Ctrl-G`, and `Ctrl-g` all |
| 41 |
mean the same thing. However, for `Alt` this is not the case: `AltG` and `Alt-G` |
| 42 |
mean `Alt-Shift-g`, while `Alt-g` does not require the Shift modifier. |
| 43 |
|
| 44 |
In addition to editing your `~/.config/micro/bindings.json`, you can run |
| 45 |
`>bind <keycombo> <action>` For a list of bindable actions, see below. |
| 46 |
|
| 47 |
You can also chain commands when rebinding. For example, if you want `Alt-s` to |
| 48 |
save and quit you can bind it like so: |
| 49 |
|
| 50 |
```json |
| 51 |
{ |
| 52 |
"Alt-s": "Save,Quit" |
| 53 |
} |
| 54 |
``` |
| 55 |
|
| 56 |
Each action will return a success flag. Actions can be chained such that |
| 57 |
the chain only continues when there are successes, or failures, or either. |
| 58 |
The `,` separator will always chain to the next action. The `|` separator |
| 59 |
will abort the chain if the action preceding it succeeds, and the `&` will |
| 60 |
abort the chain if the action preceding it fails. For example, in the default |
| 61 |
bindings, tab is bound as |
| 62 |
|
| 63 |
``` |
| 64 |
"Tab": "Autocomplete|IndentSelection|InsertTab" |
| 65 |
``` |
| 66 |
|
| 67 |
This means that if the `Autocomplete` action is successful, the chain will |
| 68 |
abort. Otherwise, it will try `IndentSelection`, and if that fails too, it |
| 69 |
will execute `InsertTab`. To use `,`, `|` or `&` in an action (as an argument |
| 70 |
to a command, for example), escape it with `\` or wrap it in single or double |
| 71 |
quotes. |
| 72 |
|
| 73 |
If the action has an `onAction` lua callback, for example `onAutocomplete` (see |
| 74 |
`> help plugins`), then the action is only considered successful if the action |
| 75 |
itself succeeded *and* the callback returned true. If there are multiple |
| 76 |
`onAction` callbacks for this action, registered by multiple plugins, then the |
| 77 |
action is only considered successful if the action itself succeeded and all the |
| 78 |
callbacks returned true. |
| 79 |
|
| 80 |
## Binding commands |
| 81 |
|
| 82 |
You can also bind a key to execute a command in command mode (see |
| 83 |
`help commands`). Simply prepend the binding with `command:`. For example: |
| 84 |
|
| 85 |
```json |
| 86 |
{ |
| 87 |
"Alt-p": "command:pwd" |
| 88 |
} |
| 89 |
``` |
| 90 |
|
| 91 |
**Note for macOS**: By default, macOS terminals do not forward alt events and |
| 92 |
instead insert unicode characters. To fix this, do the following: |
| 93 |
|
| 94 |
* iTerm2: select `Esc+` for `Left Option Key` in `Preferences->Profiles->Keys`. |
| 95 |
* Terminal.app: Enable `Use Option key as Meta key` in `Preferences->Profiles->Keyboard`. |
| 96 |
|
| 97 |
Now when you press `Alt-p` the `pwd` command will be executed which will show |
| 98 |
your working directory in the infobar. |
| 99 |
|
| 100 |
You can also bind an "editable" command with `command-edit:`. This means that |
| 101 |
micro won't immediately execute the command when you press the binding, but |
| 102 |
instead just place the string in the infobar in command mode. For example, |
| 103 |
you could rebind `Ctrl-g` to `> help`: |
| 104 |
|
| 105 |
```json |
| 106 |
{ |
| 107 |
"Ctrl-g": "command-edit:help " |
| 108 |
} |
| 109 |
``` |
| 110 |
|
| 111 |
Now when you press `Ctrl-g`, `help` will appear in the command bar and your |
| 112 |
cursor will be placed after it (note the space in the json that controls the |
| 113 |
cursor placement). |
| 114 |
|
| 115 |
## Binding Lua functions |
| 116 |
|
| 117 |
You can also bind a key to a Lua function provided by a plugin, or by your own |
| 118 |
`~/.config/micro/init.lua`. For example: |
| 119 |
|
| 120 |
```json |
| 121 |
{ |
| 122 |
"Alt-q": "lua:foo.bar" |
| 123 |
} |
| 124 |
``` |
| 125 |
|
| 126 |
where `foo` is the name of the plugin and `bar` is the name of the lua function |
| 127 |
in it, e.g.: |
| 128 |
|
| 129 |
```lua |
| 130 |
local micro = import("micro") |
| 131 |
|
| 132 |
function bar(bp) |
| 133 |
micro.InfoBar():Message("Bar action triggered") |
| 134 |
return true |
| 135 |
end |
| 136 |
``` |
| 137 |
|
| 138 |
See `> help plugins` for more informations on how to write lua functions. |
| 139 |
|
| 140 |
For `~/.config/micro/init.lua` the plugin name is `initlua` (so the keybinding |
| 141 |
in this example would be `"Alt-q": "lua:initlua.bar"`). |
| 142 |
|
| 143 |
The currently active bufpane is passed to the lua function as the argument. If |
| 144 |
the key is a mouse button, e.g. `MouseLeft` or `MouseWheelUp`, the mouse event |
| 145 |
info is passed to the lua function as the second argument, of type |
| 146 |
`*tcell.EventMouse`. See https://pkg.go.dev/github.com/micro-editor/tcell/v2#EventMouse |
| 147 |
for the description of this type and its methods. |
| 148 |
|
| 149 |
The return value of the lua function defines whether the action has succeeded. |
| 150 |
This is used when chaining lua functions with other actions. They can be chained |
| 151 |
the same way as regular actions as described above, for example: |
| 152 |
|
| 153 |
``` |
| 154 |
"Alt-q": "lua:initlua.bar|Quit" |
| 155 |
``` |
| 156 |
|
| 157 |
## Binding raw escape sequences |
| 158 |
|
| 159 |
Only read this section if you are interested in binding keys that aren't on the |
| 160 |
list of supported keys for binding. |
| 161 |
|
| 162 |
One of the drawbacks of using a terminal-based editor is that the editor must |
| 163 |
get all of its information about key events through the terminal. The terminal |
| 164 |
sends these events in the form of escape sequences often (but not always) |
| 165 |
starting with `0x1b`. |
| 166 |
|
| 167 |
For example, if micro reads `\x1b[1;5D`, on most terminals this will mean the |
| 168 |
user pressed CtrlLeft. |
| 169 |
|
| 170 |
For many key chords though, the terminal won't send any escape code or will |
| 171 |
send an escape code already in use. For example for `CtrlBackspace`, my |
| 172 |
terminal sends `\u007f` (note this doesn't start with `0x1b`), which it also |
| 173 |
sends for `Backspace` meaning micro can't bind `CtrlBackspace`. |
| 174 |
|
| 175 |
However, some terminals do allow you to bind keys to send specific escape |
| 176 |
sequences you define. Then from micro you can directly bind those escape |
| 177 |
sequences to actions. For example, to bind `CtrlBackspace` you can instruct |
| 178 |
your terminal to send `\x1bctrlback` and then bind it in `bindings.json`: |
| 179 |
|
| 180 |
```json |
| 181 |
{ |
| 182 |
"\u001bctrlback": "DeleteWordLeft" |
| 183 |
} |
| 184 |
``` |
| 185 |
|
| 186 |
Here are some instructions for sending raw escapes in different terminals |
| 187 |
|
| 188 |
### iTerm2 |
| 189 |
|
| 190 |
In iTerm2, you can do this in `Preferences->Profiles->Keys` then click the |
| 191 |
`+`, input your keybinding, and for the `Action` select `Send Escape Sequence`. |
| 192 |
For the above example your would type `ctrlback` into the box (the `\x1b`) is |
| 193 |
automatically sent by iTerm2. |
| 194 |
|
| 195 |
### Linux using loadkeys |
| 196 |
|
| 197 |
You can do this in linux using the loadkeys program. |
| 198 |
|
| 199 |
Coming soon! |
| 200 |
|
| 201 |
## Unbinding keys |
| 202 |
|
| 203 |
It is also possible to disable any of the default key bindings by use of the |
| 204 |
`None` action in the user's `bindings.json` file. |
| 205 |
|
| 206 |
## Bindable actions and bindable keys |
| 207 |
|
| 208 |
The list of default keybindings contains most of the possible actions and keys |
| 209 |
which you can use, but not all of them. Here is a full list of both. |
| 210 |
|
| 211 |
Full list of possible actions: |
| 212 |
|
| 213 |
``` |
| 214 |
CursorUp |
| 215 |
CursorDown |
| 216 |
CursorPageUp |
| 217 |
CursorPageDown |
| 218 |
CursorLeft |
| 219 |
CursorRight |
| 220 |
CursorStart |
| 221 |
CursorEnd |
| 222 |
CursorToViewTop |
| 223 |
CursorToViewCenter |
| 224 |
CursorToViewBottom |
| 225 |
SelectToStart |
| 226 |
SelectToEnd |
| 227 |
SelectUp |
| 228 |
SelectDown |
| 229 |
SelectLeft |
| 230 |
SelectRight |
| 231 |
WordRight |
| 232 |
WordLeft |
| 233 |
SubWordRight |
| 234 |
SubWordLeft |
| 235 |
SelectWordRight |
| 236 |
SelectWordLeft |
| 237 |
SelectSubWordRight |
| 238 |
SelectSubWordLeft |
| 239 |
DeleteWordRight |
| 240 |
DeleteWordLeft |
| 241 |
DeleteSubWordRight |
| 242 |
DeleteSubWordLeft |
| 243 |
SelectLine |
| 244 |
SelectToStartOfLine |
| 245 |
SelectToStartOfText |
| 246 |
SelectToStartOfTextToggle |
| 247 |
SelectToEndOfLine |
| 248 |
ParagraphPrevious |
| 249 |
ParagraphNext |
| 250 |
SelectToParagraphPrevious |
| 251 |
SelectToParagraphNext |
| 252 |
InsertNewline |
| 253 |
Backspace |
| 254 |
Delete |
| 255 |
InsertTab |
| 256 |
Save |
| 257 |
SaveAll |
| 258 |
SaveAs |
| 259 |
Find |
| 260 |
FindLiteral |
| 261 |
FindNext |
| 262 |
FindPrevious |
| 263 |
DiffNext |
| 264 |
DiffPrevious |
| 265 |
Center |
| 266 |
Undo |
| 267 |
Redo |
| 268 |
Copy |
| 269 |
CopyLine |
| 270 |
Cut |
| 271 |
CutLine |
| 272 |
Duplicate |
| 273 |
DuplicateLine |
| 274 |
DeleteLine |
| 275 |
MoveLinesUp |
| 276 |
MoveLinesDown |
| 277 |
IndentSelection |
| 278 |
OutdentSelection |
| 279 |
Autocomplete |
| 280 |
CycleAutocompleteBack |
| 281 |
OutdentLine |
| 282 |
IndentLine |
| 283 |
Paste |
| 284 |
PastePrimary |
| 285 |
SelectAll |
| 286 |
OpenFile |
| 287 |
Start |
| 288 |
End |
| 289 |
PageUp |
| 290 |
PageDown |
| 291 |
SelectPageUp |
| 292 |
SelectPageDown |
| 293 |
HalfPageUp |
| 294 |
HalfPageDown |
| 295 |
StartOfText |
| 296 |
StartOfTextToggle |
| 297 |
StartOfLine |
| 298 |
EndOfLine |
| 299 |
ToggleHelp |
| 300 |
ToggleKeyMenu |
| 301 |
ToggleDiffGutter |
| 302 |
ToggleRuler |
| 303 |
ToggleHighlightSearch |
| 304 |
UnhighlightSearch |
| 305 |
ResetSearch |
| 306 |
ClearStatus |
| 307 |
ShellMode |
| 308 |
CommandMode |
| 309 |
ToggleOverwriteMode |
| 310 |
Escape |
| 311 |
Quit |
| 312 |
QuitAll |
| 313 |
ForceQuit |
| 314 |
AddTab |
| 315 |
PreviousTab |
| 316 |
NextTab |
| 317 |
FirstTab |
| 318 |
LastTab |
| 319 |
NextSplit |
| 320 |
PreviousSplit |
| 321 |
FirstSplit |
| 322 |
LastSplit |
| 323 |
Unsplit |
| 324 |
VSplit |
| 325 |
HSplit |
| 326 |
ToggleMacro |
| 327 |
PlayMacro |
| 328 |
Suspend (Unix only) |
| 329 |
ScrollUp |
| 330 |
ScrollDown |
| 331 |
SpawnMultiCursor |
| 332 |
SpawnMultiCursorUp |
| 333 |
SpawnMultiCursorDown |
| 334 |
SpawnMultiCursorSelect |
| 335 |
RemoveMultiCursor |
| 336 |
RemoveAllMultiCursors |
| 337 |
SkipMultiCursor |
| 338 |
SkipMultiCursorBack |
| 339 |
JumpToMatchingBrace |
| 340 |
JumpLine |
| 341 |
Deselect |
| 342 |
ClearInfo |
| 343 |
None |
| 344 |
``` |
| 345 |
|
| 346 |
The `StartOfTextToggle` and `SelectToStartOfTextToggle` actions toggle between |
| 347 |
jumping to the start of the text (first) and start of the line. |
| 348 |
|
| 349 |
The `CutLine` action cuts the current line and adds it to the previously cut |
| 350 |
lines in the clipboard since the last paste (rather than just replaces the |
| 351 |
clipboard contents with this line). So you can cut multiple, not necessarily |
| 352 |
consecutive lines to the clipboard just by pressing `Ctrl-k` multiple times, |
| 353 |
without selecting them. If you want the more traditional behavior i.e. just |
| 354 |
rewrite the clipboard every time, you can use `CopyLine,DeleteLine` action |
| 355 |
instead of `CutLine`. |
| 356 |
|
| 357 |
You can also bind some mouse actions (these must be bound to mouse buttons) |
| 358 |
|
| 359 |
``` |
| 360 |
MousePress |
| 361 |
MouseDrag |
| 362 |
MouseRelease |
| 363 |
MouseMultiCursor |
| 364 |
``` |
| 365 |
|
| 366 |
Here is the list of all possible keys you can bind: |
| 367 |
|
| 368 |
``` |
| 369 |
Up |
| 370 |
Down |
| 371 |
Right |
| 372 |
Left |
| 373 |
UpLeft |
| 374 |
UpRight |
| 375 |
DownLeft |
| 376 |
DownRight |
| 377 |
Center |
| 378 |
PageUp |
| 379 |
PageDown |
| 380 |
Home |
| 381 |
End |
| 382 |
Insert |
| 383 |
Delete |
| 384 |
Help |
| 385 |
Exit |
| 386 |
Clear |
| 387 |
Cancel |
| 388 |
Print |
| 389 |
Pause |
| 390 |
Backtab |
| 391 |
F1 |
| 392 |
F2 |
| 393 |
F3 |
| 394 |
F4 |
| 395 |
F5 |
| 396 |
F6 |
| 397 |
F7 |
| 398 |
F8 |
| 399 |
F9 |
| 400 |
F10 |
| 401 |
F11 |
| 402 |
F12 |
| 403 |
F13 |
| 404 |
F14 |
| 405 |
F15 |
| 406 |
F16 |
| 407 |
F17 |
| 408 |
F18 |
| 409 |
F19 |
| 410 |
F20 |
| 411 |
F21 |
| 412 |
F22 |
| 413 |
F23 |
| 414 |
F24 |
| 415 |
F25 |
| 416 |
F26 |
| 417 |
F27 |
| 418 |
F28 |
| 419 |
F29 |
| 420 |
F30 |
| 421 |
F31 |
| 422 |
F32 |
| 423 |
F33 |
| 424 |
F34 |
| 425 |
F35 |
| 426 |
F36 |
| 427 |
F37 |
| 428 |
F38 |
| 429 |
F39 |
| 430 |
F40 |
| 431 |
F41 |
| 432 |
F42 |
| 433 |
F43 |
| 434 |
F44 |
| 435 |
F45 |
| 436 |
F46 |
| 437 |
F47 |
| 438 |
F48 |
| 439 |
F49 |
| 440 |
F50 |
| 441 |
F51 |
| 442 |
F52 |
| 443 |
F53 |
| 444 |
F54 |
| 445 |
F55 |
| 446 |
F56 |
| 447 |
F57 |
| 448 |
F58 |
| 449 |
F59 |
| 450 |
F60 |
| 451 |
F61 |
| 452 |
F62 |
| 453 |
F63 |
| 454 |
F64 |
| 455 |
CtrlSpace |
| 456 |
Ctrl-a |
| 457 |
Ctrl-b |
| 458 |
Ctrl-c |
| 459 |
Ctrl-d |
| 460 |
Ctrl-e |
| 461 |
Ctrl-f |
| 462 |
Ctrl-g |
| 463 |
Ctrl-h |
| 464 |
Ctrl-i |
| 465 |
Ctrl-j |
| 466 |
Ctrl-k |
| 467 |
Ctrl-l |
| 468 |
Ctrl-m |
| 469 |
Ctrl-n |
| 470 |
Ctrl-o |
| 471 |
Ctrl-p |
| 472 |
Ctrl-q |
| 473 |
Ctrl-r |
| 474 |
Ctrl-s |
| 475 |
Ctrl-t |
| 476 |
Ctrl-u |
| 477 |
Ctrl-v |
| 478 |
Ctrl-w |
| 479 |
Ctrl-x |
| 480 |
Ctrl-y |
| 481 |
Ctrl-z |
| 482 |
CtrlLeftSq |
| 483 |
CtrlBackslash |
| 484 |
CtrlRightSq |
| 485 |
CtrlCarat |
| 486 |
CtrlUnderscore |
| 487 |
Backspace |
| 488 |
OldBackspace |
| 489 |
Tab |
| 490 |
Esc |
| 491 |
Escape |
| 492 |
Enter |
| 493 |
``` |
| 494 |
|
| 495 |
You can also bind some mouse buttons (they may be bound to normal actions or |
| 496 |
mouse actions) |
| 497 |
|
| 498 |
``` |
| 499 |
MouseLeft |
| 500 |
MouseLeftDrag |
| 501 |
MouseLeftRelease |
| 502 |
MouseMiddle |
| 503 |
MouseMiddleDrag |
| 504 |
MouseMiddleRelease |
| 505 |
MouseRight |
| 506 |
MouseRightDrag |
| 507 |
MouseRightRelease |
| 508 |
MouseWheelUp |
| 509 |
MouseWheelDown |
| 510 |
MouseWheelLeft |
| 511 |
MouseWheelRight |
| 512 |
``` |
| 513 |
|
| 514 |
## Key sequences |
| 515 |
|
| 516 |
Key sequences can be bound by specifying valid keys one after another in brackets, such |
| 517 |
as `<Ctrl-x><Ctrl-c>`. |
| 518 |
|
| 519 |
# Default keybinding configuration. |
| 520 |
|
| 521 |
A select few keybindings are different on MacOS compared to other |
| 522 |
operating systems. This is because different OSes have different |
| 523 |
conventions for text editing defaults. |
| 524 |
|
| 525 |
```json |
| 526 |
{ |
| 527 |
"Up": "CursorUp", |
| 528 |
"Down": "CursorDown", |
| 529 |
"Right": "CursorRight", |
| 530 |
"Left": "CursorLeft", |
| 531 |
"ShiftUp": "SelectUp", |
| 532 |
"ShiftDown": "SelectDown", |
| 533 |
"ShiftLeft": "SelectLeft", |
| 534 |
"ShiftRight": "SelectRight", |
| 535 |
"AltLeft": "WordLeft", (Mac) |
| 536 |
"AltRight": "WordRight", (Mac) |
| 537 |
"AltUp": "MoveLinesUp", |
| 538 |
"AltDown": "MoveLinesDown", |
| 539 |
"CtrlShiftRight": "SelectWordRight", |
| 540 |
"CtrlShiftLeft": "SelectWordLeft", |
| 541 |
"AltLeft": "StartOfTextToggle", |
| 542 |
"AltRight": "EndOfLine", |
| 543 |
"AltShiftRight": "SelectWordRight", (Mac) |
| 544 |
"AltShiftLeft": "SelectWordLeft", (Mac) |
| 545 |
"CtrlLeft": "StartOfText", (Mac) |
| 546 |
"CtrlRight": "EndOfLine", (Mac) |
| 547 |
"AltShiftLeft": "SelectToStartOfTextToggle", |
| 548 |
"CtrlShiftLeft": "SelectToStartOfTextToggle", (Mac) |
| 549 |
"ShiftHome": "SelectToStartOfTextToggle", |
| 550 |
"AltShiftRight": "SelectToEndOfLine", |
| 551 |
"CtrlShiftRight": "SelectToEndOfLine", (Mac) |
| 552 |
"ShiftEnd": "SelectToEndOfLine", |
| 553 |
"CtrlUp": "CursorStart", |
| 554 |
"CtrlDown": "CursorEnd", |
| 555 |
"CtrlShiftUp": "SelectToStart", |
| 556 |
"CtrlShiftDown": "SelectToEnd", |
| 557 |
"Alt-{": "ParagraphPrevious", |
| 558 |
"Alt-}": "ParagraphNext", |
| 559 |
"Enter": "InsertNewline", |
| 560 |
"Ctrl-h": "Backspace", |
| 561 |
"Backspace": "Backspace", |
| 562 |
"Alt-CtrlH": "DeleteWordLeft", |
| 563 |
"Alt-Backspace": "DeleteWordLeft", |
| 564 |
"Tab": "Autocomplete|IndentSelection|InsertTab", |
| 565 |
"Backtab": "OutdentSelection|OutdentLine", |
| 566 |
"Ctrl-o": "OpenFile", |
| 567 |
"Ctrl-s": "Save", |
| 568 |
"Ctrl-f": "Find", |
| 569 |
"Alt-F": "FindLiteral", |
| 570 |
"Ctrl-n": "FindNext", |
| 571 |
"Ctrl-p": "FindPrevious", |
| 572 |
"Alt-[": "DiffPrevious|CursorStart", |
| 573 |
"Alt-]": "DiffNext|CursorEnd", |
| 574 |
"Ctrl-z": "Undo", |
| 575 |
"Ctrl-y": "Redo", |
| 576 |
"Ctrl-c": "Copy|CopyLine", |
| 577 |
"Ctrl-x": "Cut|CutLine", |
| 578 |
"Ctrl-k": "CutLine", |
| 579 |
"Ctrl-d": "Duplicate|DuplicateLine", |
| 580 |
"Ctrl-v": "Paste", |
| 581 |
"Ctrl-a": "SelectAll", |
| 582 |
"Ctrl-t": "AddTab", |
| 583 |
"Alt-,": "PreviousTab|LastTab", |
| 584 |
"Alt-.": "NextTab|FirstTab", |
| 585 |
"Home": "StartOfText", |
| 586 |
"End": "EndOfLine", |
| 587 |
"CtrlHome": "CursorStart", |
| 588 |
"CtrlEnd": "CursorEnd", |
| 589 |
"PageUp": "CursorPageUp", |
| 590 |
"PageDown": "CursorPageDown", |
| 591 |
"CtrlPageUp": "PreviousTab|LastTab", |
| 592 |
"CtrlPageDown": "NextTab|FirstTab", |
| 593 |
"ShiftPageUp": "SelectPageUp", |
| 594 |
"ShiftPageDown": "SelectPageDown", |
| 595 |
"Ctrl-g": "ToggleHelp", |
| 596 |
"Alt-g": "ToggleKeyMenu", |
| 597 |
"Ctrl-r": "ToggleRuler", |
| 598 |
"Ctrl-l": "command-edit:goto ", |
| 599 |
"Delete": "Delete", |
| 600 |
"Ctrl-b": "ShellMode", |
| 601 |
"Ctrl-q": "Quit", |
| 602 |
"Ctrl-e": "CommandMode", |
| 603 |
"Ctrl-w": "NextSplit|FirstSplit", |
| 604 |
"Ctrl-u": "ToggleMacro", |
| 605 |
"Ctrl-j": "PlayMacro", |
| 606 |
"Insert": "ToggleOverwriteMode", |
| 607 |
|
| 608 |
// Emacs-style keybindings |
| 609 |
"Alt-f": "WordRight", |
| 610 |
"Alt-b": "WordLeft", |
| 611 |
"Alt-a": "StartOfLine", |
| 612 |
"Alt-e": "EndOfLine", |
| 613 |
|
| 614 |
// Integration with file managers |
| 615 |
"F2": "Save", |
| 616 |
"F3": "Find", |
| 617 |
"F4": "Quit", |
| 618 |
"F7": "Find", |
| 619 |
"F10": "Quit", |
| 620 |
"Esc": "Escape", |
| 621 |
|
| 622 |
// Mouse bindings |
| 623 |
"MouseWheelUp": "ScrollUp", |
| 624 |
"MouseWheelDown": "ScrollDown", |
| 625 |
"MouseLeft": "MousePress", |
| 626 |
"MouseLeftDrag": "MouseDrag", |
| 627 |
"MouseLeftRelease": "MouseRelease", |
| 628 |
"MouseMiddle": "PastePrimary", |
| 629 |
"Ctrl-MouseLeft": "MouseMultiCursor", |
| 630 |
|
| 631 |
// Multi-cursor bindings |
| 632 |
"Alt-n": "SpawnMultiCursor", |
| 633 |
"AltShiftUp": "SpawnMultiCursorUp", |
| 634 |
"AltShiftDown": "SpawnMultiCursorDown", |
| 635 |
"Alt-m": "SpawnMultiCursorSelect", |
| 636 |
"Alt-p": "RemoveMultiCursor", |
| 637 |
"Alt-c": "RemoveAllMultiCursors", |
| 638 |
"Alt-x": "SkipMultiCursor", |
| 639 |
} |
| 640 |
``` |
| 641 |
|
| 642 |
## Pane type bindings |
| 643 |
|
| 644 |
Keybindings can be specified for different pane types as well. For example, to |
| 645 |
make a binding that only affects the command bar, use the `command` subgroup: |
| 646 |
|
| 647 |
``` |
| 648 |
{ |
| 649 |
"command": { |
| 650 |
"Ctrl-w": "WordLeft" |
| 651 |
} |
| 652 |
} |
| 653 |
``` |
| 654 |
|
| 655 |
The possible pane types are `buffer` (normal buffer), `command` (command bar), |
| 656 |
and `terminal` (terminal pane). The defaults for the command and terminal panes |
| 657 |
are given below: |
| 658 |
|
| 659 |
``` |
| 660 |
{ |
| 661 |
"terminal": { |
| 662 |
"<Ctrl-q><Ctrl-q>": "Exit", |
| 663 |
"<Ctrl-e><Ctrl-e>": "CommandMode", |
| 664 |
"<Ctrl-w><Ctrl-w>": "NextSplit" |
| 665 |
}, |
| 666 |
|
| 667 |
"command": { |
| 668 |
"Up": "HistoryUp", |
| 669 |
"Down": "HistoryDown", |
| 670 |
"Right": "CursorRight", |
| 671 |
"Left": "CursorLeft", |
| 672 |
"ShiftUp": "SelectUp", |
| 673 |
"ShiftDown": "SelectDown", |
| 674 |
"ShiftLeft": "SelectLeft", |
| 675 |
"ShiftRight": "SelectRight", |
| 676 |
"AltLeft": "StartOfTextToggle", |
| 677 |
"AltRight": "EndOfLine", |
| 678 |
"AltUp": "CursorStart", |
| 679 |
"AltDown": "CursorEnd", |
| 680 |
"AltShiftRight": "SelectWordRight", |
| 681 |
"AltShiftLeft": "SelectWordLeft", |
| 682 |
"CtrlLeft": "WordLeft", |
| 683 |
"CtrlRight": "WordRight", |
| 684 |
"CtrlShiftLeft": "SelectToStartOfTextToggle", |
| 685 |
"ShiftHome": "SelectToStartOfTextToggle", |
| 686 |
"CtrlShiftRight": "SelectToEndOfLine", |
| 687 |
"ShiftEnd": "SelectToEndOfLine", |
| 688 |
"CtrlUp": "CursorStart", |
| 689 |
"CtrlDown": "CursorEnd", |
| 690 |
"CtrlShiftUp": "SelectToStart", |
| 691 |
"CtrlShiftDown": "SelectToEnd", |
| 692 |
"Enter": "ExecuteCommand", |
| 693 |
"CtrlH": "Backspace", |
| 694 |
"Backspace": "Backspace", |
| 695 |
"OldBackspace": "Backspace", |
| 696 |
"Alt-CtrlH": "DeleteWordLeft", |
| 697 |
"Alt-Backspace": "DeleteWordLeft", |
| 698 |
"Tab": "CommandComplete", |
| 699 |
"Backtab": "CycleAutocompleteBack", |
| 700 |
"Ctrl-z": "Undo", |
| 701 |
"Ctrl-y": "Redo", |
| 702 |
"Ctrl-c": "Copy|CopyLine", |
| 703 |
"Ctrl-x": "Cut|CutLine", |
| 704 |
"Ctrl-k": "CutLine", |
| 705 |
"Ctrl-v": "Paste", |
| 706 |
"Home": "StartOfTextToggle", |
| 707 |
"End": "EndOfLine", |
| 708 |
"CtrlHome": "CursorStart", |
| 709 |
"CtrlEnd": "CursorEnd", |
| 710 |
"Delete": "Delete", |
| 711 |
"Ctrl-q": "AbortCommand", |
| 712 |
"Ctrl-e": "EndOfLine", |
| 713 |
"Ctrl-a": "StartOfLine", |
| 714 |
"Ctrl-w": "DeleteWordLeft", |
| 715 |
"Insert": "ToggleOverwriteMode", |
| 716 |
"Ctrl-b": "WordLeft", |
| 717 |
"Ctrl-f": "WordRight", |
| 718 |
"Ctrl-d": "DeleteWordLeft", |
| 719 |
"Ctrl-m": "ExecuteCommand", |
| 720 |
"Ctrl-n": "HistoryDown", |
| 721 |
"Ctrl-p": "HistoryUp", |
| 722 |
"Ctrl-u": "SelectToStart", |
| 723 |
|
| 724 |
// Emacs-style keybindings |
| 725 |
"Alt-f": "WordRight", |
| 726 |
"Alt-b": "WordLeft", |
| 727 |
"Alt-a": "StartOfText", |
| 728 |
"Alt-e": "EndOfLine", |
| 729 |
|
| 730 |
// Integration with file managers |
| 731 |
"F10": "AbortCommand", |
| 732 |
"Esc": "AbortCommand", |
| 733 |
|
| 734 |
// Mouse bindings |
| 735 |
"MouseWheelUp": "HistoryUp", |
| 736 |
"MouseWheelDown": "HistoryDown", |
| 737 |
"MouseLeft": "MousePress", |
| 738 |
"MouseLeftDrag": "MouseDrag", |
| 739 |
"MouseLeftRelease": "MouseRelease", |
| 740 |
"MouseMiddle": "PastePrimary" |
| 741 |
} |
| 742 |
} |
| 743 |
``` |
| 744 |
|
| 745 |
## Final notes |
| 746 |
|
| 747 |
Note: On some old terminal emulators and on Windows machines, `Ctrl-h` should be |
| 748 |
used for backspace. |
| 749 |
|
| 750 |
Additionally, alt keys can be bound by using `Alt-key`. For example `Alt-a` or |
| 751 |
`Alt-Up`. Micro supports an optional `-` between modifiers like `Alt` and |
| 752 |
`Ctrl` so `Alt-a` could be rewritten as `Alta` (case matters for alt bindings). |
| 753 |
This is why in the default keybindings you can see `AltShiftLeft` instead of |
| 754 |
`Alt-ShiftLeft` (they are equivalent). |
| 755 |
|
| 756 |
Please note that terminal emulators are strange applications and micro only |
| 757 |
receives key events that the terminal decides to send. Some terminal emulators |
| 758 |
may not send certain events even if this document says micro can receive the |
| 759 |
event. To see exactly what micro receives from the terminal when you press a |
| 760 |
key, run the `> raw` command. |