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.
6 Custom keybindings are stored internally in micro if changed with the `> bind`
7 command or you 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).
14 If `~/.config/micro/bindings.json` does not exist, you can simply create it.
15 Micro will know what to do with it.
17 You can use the alt keys + arrows to move word by word. Ctrl left and right
18 move the cursor to the start and end of the line, and ctrl up and down move the
19 cursor the start and end of the buffer.
21 You can hold shift with all of these movement actions to select while moving.
25 The bindings may be rebound using the `~/.config/micro/bindings.json` file.
26 Each key is bound to an action.
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.
38 In addition to editing your `~/.config/micro/bindings.json`, you can run
39 `>bind <keycombo> <action>` For a list of bindable actions, see below.
41 You can also chain commands when rebinding. For example, if you want Alt-s to
42 save and quit you can bind it like so:
50 Each action will return a success flag. Actions can be chained such that
51 the chain only continues when there are successes, or failures, or either.
52 The `,` separator will always chain to the next action. The `|` separator
53 will abort the chain if the action preceding it succeeds, and the `&` will
54 abort the chain if the action preceding it fails. For example, in the default
55 bindings, tab is bound as
58 "Tab": "Autocomplete|IndentSelection|InsertTab"
61 This means that if the `Autocomplete` action is successful, the chain will
62 abort. Otherwise, it will try `IndentSelection`, and if that fails too, it
63 will execute `InsertTab`.
67 You can also bind a key to execute a command in command mode (see
68 `help commands`). Simply prepend the binding with `command:`. For example:
72 "Alt-p": "command:pwd"
76 Now when you press `Alt-p` the `pwd` command will be executed which will show
77 your working directory in the infobar.
79 You can also bind an "editable" command with `command-edit:`. This means that
80 micro won't immediately execute the command when you press the binding, but
81 instead just place the string in the infobar in command mode. For example,
82 you could rebind `CtrlG` to `> help`:
86 "CtrlG": "command-edit:help "
90 Now when you press `CtrlG`, `help` will appear in the command bar and your
91 cursor will be placed after it (note the space in the json that controls the
94 ## Binding raw escape sequences
96 Only read this section if you are interested in binding keys that aren't on the
97 list of supported keys for binding.
99 One of the drawbacks of using a terminal-based editor is that the editor must
100 get all of its information about key events through the terminal. The terminal
101 sends these events in the form of escape sequences often (but not always)
102 starting with `0x1b`.
104 For example, if micro reads `\x1b[1;5D`, on most terminals this will mean the
105 user pressed CtrlLeft.
107 For many key chords though, the terminal won't send any escape code or will
108 send an escape code already in use. For example for `CtrlBackspace`, my
109 terminal sends `\u007f` (note this doesn't start with `0x1b`), which it also
110 sends for `Backspace` meaning micro can't bind `CtrlBackspace`.
112 However, some terminals do allow you to bind keys to send specific escape
113 sequences you define. Then from micro you can directly bind those escape
114 sequences to actions. For example, to bind `CtrlBackspace` you can instruct
115 your terminal to send `\x1bctrlback` and then bind it in `bindings.json`:
119 "\u001bctrlback": "DeleteWordLeft"
123 Here are some instructions for sending raw escapes in different terminals
127 In iTerm2, you can do this in `Preferences->Profiles->Keys` then click the
128 `+`, input your keybinding, and for the `Action` select `Send Escape Sequence`.
129 For the above example your would type `ctrlback` into the box (the `\x1b`) is
130 automatically sent by iTerm2.
132 ### Linux using loadkeys
134 You can do this in linux using the loadkeys program.
140 It is also possible to disable any of the default key bindings by use of the
141 `None` action in the user's `bindings.json` file.
143 ## Bindable actions and bindable keys
145 The list of default keybindings contains most of the possible actions and keys
146 which you can use, but not all of them. Here is a full list of both.
148 Full list of possible actions:
237 SpawnMultiCursorSelect
239 RemoveAllMultiCursors
246 You can also bind some mouse actions (these must be bound to mouse buttons)
253 Here is the list of all possible keys you can bind:
382 You can also bind some mouse buttons (they may be bound to normal actions or
395 # Default keybinding configuration.
397 A select few keybindings are different on MacOS compared to other
398 operating systems. This is because different OSes have different
399 conventions for text editing defaults.
404 "Down": "CursorDown",
405 "Right": "CursorRight",
406 "Left": "CursorLeft",
407 "ShiftUp": "SelectUp",
408 "ShiftDown": "SelectDown",
409 "ShiftLeft": "SelectLeft",
410 "ShiftRight": "SelectRight",
411 "AltLeft": "WordLeft",
412 "AltRight": "WordRight",
413 "AltUp": "MoveLinesUp",
414 "AltDown": "MoveLinesDown",
415 "CtrlShiftRight": "SelectWordRight",
416 "CtrlShiftLeft": "SelectWordLeft",
417 "AltLeft": "StartOfLine",
418 "AltRight": "EndOfLine",
419 "AltShiftRight": "SelectWordRight", (Mac)
420 "AltShiftLeft": "SelectWordLeft", (Mac)
421 "CtrlLeft": "StartOfText", (Mac)
422 "CtrlRight": "EndOfLine", (Mac)
423 "AltShiftLeft": "SelectToStartOfLine",
424 "CtrlShiftLeft": "SelectToStartOfText", (Mac)
425 "ShiftHome": "SelectToStartOfLine",
426 "AltShiftRight": "SelectToEndOfLine",
427 "CtrlShiftRight": "SelectToEndOfLine", (Mac)
428 "ShiftEnd": "SelectToEndOfLine",
429 "CtrlUp": "CursorStart",
430 "CtrlDown": "CursorEnd",
431 "CtrlShiftUp": "SelectToStart",
432 "CtrlShiftDown": "SelectToEnd",
433 "Alt-{": "ParagraphPrevious",
434 "Alt-}": "ParagraphNext",
435 "Enter": "InsertNewline",
436 "CtrlH": "Backspace",
437 "Backspace": "Backspace",
438 "Alt-CtrlH": "DeleteWordLeft",
439 "Alt-Backspace": "DeleteWordLeft",
440 "Tab": "Autocomplete|IndentSelection|InsertTab",
441 "Backtab": "OutdentSelection|OutdentLine",
446 "CtrlP": "FindPrevious",
452 "CtrlD": "DuplicateLine",
454 "CtrlA": "SelectAll",
456 "Alt,": "PreviousTab",
458 "Home": "StartOfLine",
460 "CtrlHome": "CursorStart",
461 "CtrlEnd": "CursorEnd",
462 "PageUp": "CursorPageUp",
463 "PageDown": "CursorPageDown",
464 "CtrlPageUp": "PreviousTab",
465 "CtrlPageDown": "NextTab",
466 "CtrlG": "ToggleHelp",
467 "Alt-g": "ToggleKeyMenu",
468 "CtrlR": "ToggleRuler",
469 "CtrlL": "command-edit:goto ",
471 "CtrlB": "ShellMode",
473 "CtrlE": "CommandMode",
474 "CtrlW": "NextSplit",
475 "CtrlU": "ToggleMacro",
476 "CtrlJ": "PlayMacro",
477 "Insert": "ToggleOverwriteMode",
479 // Emacs-style keybindings
480 "Alt-f": "WordRight",
482 "Alt-a": "StartOfLine",
483 "Alt-e": "EndOfLine",
485 // Integration with file managers
494 "MouseWheelUp": "ScrollUp",
495 "MouseWheelDown": "ScrollDown",
496 "MouseLeft": "MousePress",
497 "MouseMiddle": "PastePrimary",
498 "Ctrl-MouseLeft": "MouseMultiCursor",
500 "Alt-n": "SpawnMultiCursor",
501 "AltShiftUp": "SpawnMultiCursorUp",
502 "AltShiftDown": "SpawnMultiCursorDown",
503 "Alt-m": "SpawnMultiCursorSelect",
504 "Alt-p": "RemoveMultiCursor",
505 "Alt-c": "RemoveAllMultiCursors",
506 "Alt-x": "SkipMultiCursor",
512 Note: On some old terminal emulators and on Windows machines, `CtrlH` should be
515 Additionally, alt keys can be bound by using `Alt-key`. For example `Alt-a` or
516 `Alt-Up`. Micro supports an optional `-` between modifiers like `Alt` and
517 `Ctrl` so `Alt-a` could be rewritten as `Alta` (case matters for alt bindings).
518 This is why in the default keybindings you can see `AltShiftLeft` instead of
519 `Alt-ShiftLeft` (they are equivalent).
521 Please note that terminal emulators are strange applications and micro only
522 receives key events that the terminal decides to send. Some terminal emulators
523 may not send certain events even if this document says micro can receive the
524 event. To see exactly what micro receives from the terminal when you press a
525 key, run the `> raw` command.