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 move
18 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. Each
26 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 abort.
62 Otherwise, it will try `IndentSelection`, and if that fails too, it will
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 cursor will
91 be placed after it (note the space in the json that controls the cursor placement).
93 ## Binding raw escape sequences
95 Only read this section if you are interested in binding keys that aren't on the
96 list of supported keys for binding.
98 One of the drawbacks of using a terminal-based editor is that the editor must
99 get all of its information about key events through the terminal. The terminal
100 sends these events in the form of escape sequences often (but not always)
101 starting with `0x1b`.
103 For example, if micro reads `\x1b[1;5D`, on most terminals this will mean the
104 user pressed CtrlLeft.
106 For many key chords though, the terminal won't send any escape code or will send
107 an escape code already in use. For example for `CtrlBackspace`, my terminal
108 sends `\u007f` (note this doesn't start with `0x1b`), which it also sends for
109 `Backspace` meaning micro can't bind `CtrlBackspace`.
111 However, some terminals do allow you to bind keys to send specific escape
112 sequences you define. Then from micro you can directly bind those escape
113 sequences to actions. For example, to bind `CtrlBackspace` you can instruct your
114 terminal to send `\x1bctrlback` and then bind it in `bindings.json`:
118 "\u001bctrlback": "DeleteWordLeft"
122 Here are some instructions for sending raw escapes in different terminals
126 In iTerm2, you can do this in `Preferences->Profiles->Keys` then click the `+`,
127 input your keybinding, and for the `Action` select `Send Escape Sequence`. For
128 the above example your would type `ctrlback` into the box (the `\x1b`) is
129 automatically sent by iTerm2.
131 ### Linux using loadkeys
133 You can do this in linux using the loadkeys program.
139 It is also possible to disable any of the default key bindings by use of the
140 `None` action in the user's `bindings.json` file.
142 ## Bindable actions and bindable keys
144 The list of default keybindings contains most of the possible actions and keys
145 which you can use, but not all of them. Here is a full list of both.
147 Full list of possible actions:
233 SpawnMultiCursorSelect
235 RemoveAllMultiCursors
242 You can also bind some mouse actions (these must be bound to mouse buttons)
249 Here is the list of all possible keys you can bind:
378 You can also bind some mouse buttons (they may be bound to normal actions or
391 # Default keybinding configuration.
396 "Down": "CursorDown",
397 "Right": "CursorRight",
398 "Left": "CursorLeft",
399 "ShiftUp": "SelectUp",
400 "ShiftDown": "SelectDown",
401 "ShiftLeft": "SelectLeft",
402 "ShiftRight": "SelectRight",
403 "AltLeft": "WordLeft",
404 "AltRight": "WordRight",
405 "AltUp": "MoveLinesUp",
406 "AltDown": "MoveLinesDown",
407 "AltShiftRight": "SelectWordRight",
408 "AltShiftLeft": "SelectWordLeft",
409 "CtrlLeft": "StartOfLine",
410 "CtrlRight": "EndOfLine",
411 "CtrlShiftLeft": "SelectToStartOfLine",
412 "ShiftHome": "SelectToStartOfLine",
413 "CtrlShiftRight": "SelectToEndOfLine",
414 "ShiftEnd": "SelectToEndOfLine",
415 "CtrlUp": "CursorStart",
416 "CtrlDown": "CursorEnd",
417 "CtrlShiftUp": "SelectToStart",
418 "CtrlShiftDown": "SelectToEnd",
419 "Alt-{": "ParagraphPrevious",
420 "Alt-}": "ParagraphNext",
421 "Enter": "InsertNewline",
422 "CtrlH": "Backspace",
423 "Backspace": "Backspace",
424 "Alt-CtrlH": "DeleteWordLeft",
425 "Alt-Backspace": "DeleteWordLeft",
426 "Tab": "Autocomplete|IndentSelection|InsertTab",
427 "Backtab": "OutdentSelection|OutdentLine",
432 "CtrlP": "FindPrevious",
438 "CtrlD": "DuplicateLine",
440 "CtrlA": "SelectAll",
442 "Alt,": "PreviousTab",
444 "Home": "StartOfLine",
446 "CtrlHome": "CursorStart",
447 "CtrlEnd": "CursorEnd",
448 "PageUp": "CursorPageUp",
449 "PageDown": "CursorPageDown",
450 "CtrlPageUp": "PreviousTab",
451 "CtrlPageDown": "NextTab",
452 "CtrlG": "ToggleHelp",
453 "Alt-g": "ToggleKeyMenu",
454 "CtrlR": "ToggleRuler",
455 "CtrlL": "command-edit:goto ",
457 "CtrlB": "ShellMode",
459 "CtrlE": "CommandMode",
460 "CtrlW": "NextSplit",
461 "CtrlU": "ToggleMacro",
462 "CtrlJ": "PlayMacro",
463 "Insert": "ToggleOverwriteMode",
465 // Emacs-style keybindings
466 "Alt-f": "WordRight",
468 "Alt-a": "StartOfLine",
469 "Alt-e": "EndOfLine",
471 // Integration with file managers
480 "MouseWheelUp": "ScrollUp",
481 "MouseWheelDown": "ScrollDown",
482 "MouseLeft": "MousePress",
483 "MouseMiddle": "PastePrimary",
484 "Ctrl-MouseLeft": "MouseMultiCursor",
486 "Alt-n": "SpawnMultiCursor",
487 "Alt-m": "SpawnMultiCursorSelect",
488 "Alt-p": "RemoveMultiCursor",
489 "Alt-c": "RemoveAllMultiCursors",
490 "Alt-x": "SkipMultiCursor"
496 Note: On some old terminal emulators and on Windows machines, `CtrlH` should be
499 Additionally, alt keys can be bound by using `Alt-key`. For example `Alt-a` or
500 `Alt-Up`. Micro supports an optional `-` between modifiers like `Alt` and
501 `Ctrl` so `Alt-a` could be rewritten as `Alta` (case matters for alt bindings).
502 This is why in the default keybindings you can see `AltShiftLeft` instead of
503 `Alt-ShiftLeft` (they are equivalent).
505 Please note that terminal emulators are strange applications and micro only receives
506 key events that the terminal decides to send. Some terminal emulators may not
507 send certain events even if this document says micro can receive the event. To see
508 exactly what micro receives from the terminal when you press a key, run the `> raw`