2016-08-13 23:22:18 +03:00
|
|
|
# Keybindings
|
2016-07-28 22:52:31 +03:00
|
|
|
|
2017-03-01 17:30:35 +03:00
|
|
|
Micro has a plethora of hotkeys that make it easy and powerful to use and all
|
|
|
|
hotkeys are fully customizable to your liking.
|
2017-10-11 16:16:53 +03:00
|
|
|
|
2017-10-07 03:42:58 +03:00
|
|
|
Custom keybindings are stored internally in micro if changed with the `> bind`
|
2017-10-11 16:16:53 +03:00
|
|
|
command or you can also be added in the file `~/.config/micro/bindings.json` as
|
|
|
|
discussed below. For a list of the default keybindings in the json format used
|
|
|
|
by micro, please see the end of this file. For a more user-friendly list with
|
|
|
|
explanations of what the default hotkeys are and what they do, please see
|
|
|
|
`>help defaultkeys`
|
2016-07-28 22:52:31 +03:00
|
|
|
|
2017-03-01 17:30:35 +03:00
|
|
|
If `~/.config/micro/bindings.json` does not exist, you can simply create it.
|
|
|
|
Micro will know what to do with it.
|
2016-07-28 22:52:31 +03:00
|
|
|
|
2017-10-11 16:16:53 +03:00
|
|
|
You can use the alt keys + arrows to move word by word. Ctrl left and right move
|
|
|
|
the cursor to the start and end of the line, and ctrl up and down move the
|
|
|
|
cursor the start and end of the buffer.
|
2016-07-28 22:52:31 +03:00
|
|
|
|
|
|
|
You can hold shift with all of these movement actions to select while moving.
|
|
|
|
|
2016-08-13 23:22:18 +03:00
|
|
|
|
2017-10-11 16:16:53 +03:00
|
|
|
## Rebinding keys
|
|
|
|
|
|
|
|
The bindings may be rebound using the `~/.config/micro/bindings.json` file. Each
|
|
|
|
key is bound to an action.
|
2016-07-28 22:52:31 +03:00
|
|
|
|
|
|
|
For example, to bind `Ctrl-y` to undo and `Ctrl-z` to redo, you could put the
|
|
|
|
following in the `bindings.json` file.
|
|
|
|
|
|
|
|
```json
|
|
|
|
{
|
|
|
|
"CtrlY": "Undo",
|
|
|
|
"CtrlZ": "Redo"
|
|
|
|
}
|
|
|
|
```
|
2016-08-13 23:22:18 +03:00
|
|
|
|
2017-03-01 17:30:35 +03:00
|
|
|
In addition to editing your `~/.config/micro/bindings.json`, you can run
|
|
|
|
`>bind <keycombo> <action>` For a list of bindable actions, see below.
|
|
|
|
|
2017-10-07 03:42:58 +03:00
|
|
|
You can also chain commands when rebinding. For example, if you want Alt-s to
|
|
|
|
save and quit you can bind it like so:
|
2016-08-13 23:22:18 +03:00
|
|
|
|
|
|
|
```json
|
|
|
|
{
|
|
|
|
"Alt-s": "Save,Quit"
|
|
|
|
}
|
|
|
|
```
|
2016-08-17 18:56:56 +03:00
|
|
|
|
2018-01-02 23:15:28 +03:00
|
|
|
## Binding commands
|
|
|
|
|
|
|
|
You can also bind a key to execute a command in command mode (see
|
|
|
|
`help commands`). Simply prepend the binding with `command:`. For example:
|
|
|
|
|
|
|
|
```json
|
|
|
|
{
|
|
|
|
"Alt-p": "command:pwd"
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
Now when you press `Alt-p` the `pwd` command will be executed which will show
|
|
|
|
your working directory in the infobar.
|
|
|
|
|
|
|
|
You can also bind an "editable" command with `command-edit:`. This means that
|
|
|
|
micro won't immediately execute the command when you press the binding, but
|
|
|
|
instead just place the string in the infobar in command mode. For example,
|
|
|
|
you could rebind `CtrlG` to `> help`:
|
|
|
|
|
|
|
|
```json
|
|
|
|
{
|
|
|
|
"CtrlG": "command-edit:help "
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
Now when you press `CtrlG`, `help` will appear in the command bar and your cursor will
|
|
|
|
be placed after it (note the space in the json that controls the cursor placement).
|
2017-10-11 16:16:53 +03:00
|
|
|
|
|
|
|
## Binding raw escape sequences
|
2017-10-07 03:42:58 +03:00
|
|
|
|
|
|
|
Only read this section if you are interested in binding keys that aren't on the
|
|
|
|
list of supported keys for binding.
|
|
|
|
|
|
|
|
One of the drawbacks of using a terminal-based editor is that the editor must
|
|
|
|
get all of its information about key events through the terminal. The terminal
|
|
|
|
sends these events in the form of escape sequences often (but not always)
|
|
|
|
starting with `0x1b`.
|
|
|
|
|
2017-10-11 16:16:53 +03:00
|
|
|
For example, if micro reads `\x1b[1;5D`, on most terminals this will mean the
|
|
|
|
user pressed CtrlLeft.
|
2017-10-07 03:42:58 +03:00
|
|
|
|
2017-10-11 16:16:53 +03:00
|
|
|
For many key chords though, the terminal won't send any escape code or will send
|
|
|
|
an escape code already in use. For example for `CtrlBackspace`, my terminal
|
|
|
|
sends `\u007f` (note this doesn't start with `0x1b`), which it also sends for
|
|
|
|
`Backspace` meaning micro can't bind `CtrlBackspace`.
|
2017-10-07 03:42:58 +03:00
|
|
|
|
|
|
|
However, some terminals do allow you to bind keys to send specific escape
|
|
|
|
sequences you define. Then from micro you can directly bind those escape
|
2017-10-11 16:16:53 +03:00
|
|
|
sequences to actions. For example, to bind `CtrlBackspace` you can instruct your
|
|
|
|
terminal to send `\x1bctrlback` and then bind it in `bindings.json`:
|
2017-10-07 03:42:58 +03:00
|
|
|
|
|
|
|
```json
|
|
|
|
{
|
|
|
|
"\u001bctrlback": "DeleteWordLeft"
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
Here are some instructions for sending raw escapes in different terminals
|
|
|
|
|
|
|
|
### iTerm2
|
|
|
|
|
2017-10-11 16:16:53 +03:00
|
|
|
In iTerm2, you can do this in `Preferences->Profiles->Keys` then click the `+`,
|
|
|
|
input your keybinding, and for the `Action` select `Send Escape Sequence`. For
|
|
|
|
the above example your would type `ctrlback` into the box (the `\x1b`) is
|
|
|
|
automatically sent by iTerm2.
|
2017-10-07 03:42:58 +03:00
|
|
|
|
|
|
|
### Linux using loadkeys
|
|
|
|
|
|
|
|
You can do this in linux using the loadkeys program.
|
|
|
|
|
|
|
|
Coming soon!
|
|
|
|
|
2017-10-11 16:16:53 +03:00
|
|
|
|
|
|
|
## Unbinding keys
|
2017-01-02 18:56:55 +03:00
|
|
|
|
|
|
|
It is also possible to disable any of the default key bindings by use of the
|
|
|
|
`UnbindKey` action in the user's `bindings.json` file.
|
|
|
|
|
2017-10-11 16:16:53 +03:00
|
|
|
|
|
|
|
## Bindable actions and bindable keys
|
2016-08-17 18:56:56 +03:00
|
|
|
|
|
|
|
The list of default keybindings contains most of the possible actions and keys
|
|
|
|
which you can use, but not all of them. Here is a full list of both.
|
|
|
|
|
|
|
|
Full list of possible actions:
|
|
|
|
|
|
|
|
```
|
|
|
|
CursorUp
|
|
|
|
CursorDown
|
|
|
|
CursorPageUp
|
|
|
|
CursorPageDown
|
|
|
|
CursorLeft
|
|
|
|
CursorRight
|
|
|
|
CursorStart
|
|
|
|
CursorEnd
|
|
|
|
SelectToStart
|
|
|
|
SelectToEnd
|
|
|
|
SelectUp
|
|
|
|
SelectDown
|
|
|
|
SelectLeft
|
|
|
|
SelectRight
|
|
|
|
WordRight
|
|
|
|
WordLeft
|
|
|
|
SelectWordRight
|
|
|
|
SelectWordLeft
|
2016-10-12 00:34:28 +03:00
|
|
|
MoveLinesUp
|
|
|
|
MoveLinesDown
|
2016-08-17 18:56:56 +03:00
|
|
|
DeleteWordRight
|
|
|
|
DeleteWordLeft
|
|
|
|
SelectToStartOfLine
|
|
|
|
SelectToEndOfLine
|
|
|
|
InsertNewline
|
|
|
|
InsertSpace
|
|
|
|
Backspace
|
|
|
|
Delete
|
2016-08-28 05:00:56 +03:00
|
|
|
Center
|
2016-08-17 18:56:56 +03:00
|
|
|
InsertTab
|
|
|
|
Save
|
2017-05-05 18:05:23 +03:00
|
|
|
SaveAll
|
2016-09-08 21:13:46 +03:00
|
|
|
SaveAs
|
2016-08-17 18:56:56 +03:00
|
|
|
Find
|
|
|
|
FindNext
|
|
|
|
FindPrevious
|
|
|
|
Undo
|
|
|
|
Redo
|
|
|
|
Copy
|
|
|
|
Cut
|
|
|
|
CutLine
|
|
|
|
DuplicateLine
|
|
|
|
DeleteLine
|
|
|
|
IndentSelection
|
|
|
|
OutdentSelection
|
|
|
|
Paste
|
|
|
|
SelectAll
|
|
|
|
OpenFile
|
|
|
|
Start
|
|
|
|
End
|
|
|
|
PageUp
|
|
|
|
PageDown
|
|
|
|
HalfPageUp
|
|
|
|
HalfPageDown
|
|
|
|
StartOfLine
|
|
|
|
EndOfLine
|
2017-10-03 05:01:01 +03:00
|
|
|
ParagraphPrevious
|
|
|
|
ParagraphNext
|
2016-08-17 18:56:56 +03:00
|
|
|
ToggleHelp
|
|
|
|
ToggleRuler
|
|
|
|
JumpLine
|
|
|
|
ClearStatus
|
|
|
|
ShellMode
|
|
|
|
CommandMode
|
|
|
|
Quit
|
2016-08-31 00:38:46 +03:00
|
|
|
QuitAll
|
2016-08-17 18:56:56 +03:00
|
|
|
AddTab
|
|
|
|
PreviousTab
|
|
|
|
NextTab
|
|
|
|
NextSplit
|
2016-10-04 18:08:32 +03:00
|
|
|
Unsplit
|
|
|
|
VSplit
|
|
|
|
HSplit
|
2016-08-17 18:56:56 +03:00
|
|
|
PreviousSplit
|
2016-09-06 17:43:45 +03:00
|
|
|
ToggleMacro
|
|
|
|
PlayMacro
|
2017-12-02 04:39:25 +03:00
|
|
|
Suspend (Unix only)
|
2017-06-18 00:36:27 +03:00
|
|
|
ScrollUp
|
|
|
|
ScrollDown
|
|
|
|
SpawnMultiCursor
|
|
|
|
RemoveMultiCursor
|
|
|
|
RemoveAllMultiCursors
|
|
|
|
SkipMultiCursor
|
2017-01-02 18:56:55 +03:00
|
|
|
UnbindKey
|
2016-08-17 18:56:56 +03:00
|
|
|
```
|
|
|
|
|
2017-06-18 00:36:27 +03:00
|
|
|
You can also bind some mouse actions (these must be bound to mouse buttons)
|
2017-10-11 16:16:53 +03:00
|
|
|
|
2017-06-18 00:36:27 +03:00
|
|
|
```
|
|
|
|
MousePress
|
|
|
|
MouseMultiCursor
|
|
|
|
```
|
|
|
|
|
2016-08-17 18:56:56 +03:00
|
|
|
Here is the list of all possible keys you can bind:
|
|
|
|
|
|
|
|
```
|
|
|
|
Up
|
|
|
|
Down
|
|
|
|
Right
|
|
|
|
Left
|
|
|
|
UpLeft
|
|
|
|
UpRight
|
|
|
|
DownLeft
|
|
|
|
DownRight
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J
|
|
|
|
CtrlK
|
|
|
|
CtrlL
|
|
|
|
CtrlM
|
|
|
|
CtrlN
|
|
|
|
CtrlO
|
|
|
|
CtrlP
|
|
|
|
CtrlQ
|
|
|
|
CtrlR
|
|
|
|
CtrlS
|
|
|
|
CtrlT
|
|
|
|
CtrlU
|
|
|
|
CtrlV
|
|
|
|
CtrlW
|
|
|
|
CtrlX
|
|
|
|
CtrlY
|
|
|
|
CtrlZ
|
|
|
|
CtrlLeftSq
|
|
|
|
CtrlBackslash
|
|
|
|
CtrlRightSq
|
|
|
|
CtrlCarat
|
|
|
|
CtrlUnderscore
|
|
|
|
Backspace
|
|
|
|
Tab
|
|
|
|
Esc
|
|
|
|
Escape
|
|
|
|
Enter
|
|
|
|
```
|
|
|
|
|
2017-10-07 03:42:58 +03:00
|
|
|
You can also bind some mouse buttons (they may be bound to normal actions or
|
|
|
|
mouse actions)
|
2017-06-18 00:36:27 +03:00
|
|
|
|
|
|
|
```
|
|
|
|
MouseLeft
|
|
|
|
MouseMiddle
|
|
|
|
MouseRight
|
|
|
|
MouseWheelUp
|
|
|
|
MouseWheelDown
|
|
|
|
MouseWheelLeft
|
|
|
|
MouseWheelRight
|
|
|
|
```
|
|
|
|
|
2017-03-01 17:30:35 +03:00
|
|
|
# Default keybinding configuration.
|
|
|
|
|
|
|
|
```json
|
|
|
|
{
|
|
|
|
"Up": "CursorUp",
|
|
|
|
"Down": "CursorDown",
|
|
|
|
"Right": "CursorRight",
|
|
|
|
"Left": "CursorLeft",
|
|
|
|
"ShiftUp": "SelectUp",
|
|
|
|
"ShiftDown": "SelectDown",
|
|
|
|
"ShiftLeft": "SelectLeft",
|
|
|
|
"ShiftRight": "SelectRight",
|
|
|
|
"AltLeft": "WordLeft",
|
|
|
|
"AltRight": "WordRight",
|
|
|
|
"AltUp": "MoveLinesUp",
|
|
|
|
"AltDown": "MoveLinesDown",
|
2017-06-18 00:36:27 +03:00
|
|
|
"AltShiftRight": "SelectWordRight",
|
|
|
|
"AltShiftLeft": "SelectWordLeft",
|
2017-03-01 17:30:35 +03:00
|
|
|
"CtrlLeft": "StartOfLine",
|
|
|
|
"CtrlRight": "EndOfLine",
|
|
|
|
"CtrlShiftLeft": "SelectToStartOfLine",
|
2017-05-07 14:19:58 +03:00
|
|
|
"ShiftHome": "SelectToStartOfLine",
|
2017-03-01 17:30:35 +03:00
|
|
|
"CtrlShiftRight": "SelectToEndOfLine",
|
2017-05-07 14:19:58 +03:00
|
|
|
"ShiftEnd": "SelectToEndOfLine",
|
2017-03-01 17:30:35 +03:00
|
|
|
"CtrlUp": "CursorStart",
|
|
|
|
"CtrlDown": "CursorEnd",
|
|
|
|
"CtrlShiftUp": "SelectToStart",
|
|
|
|
"CtrlShiftDown": "SelectToEnd",
|
2017-10-03 05:01:01 +03:00
|
|
|
"Alt-{": "ParagraphPrevious",
|
|
|
|
"Alt-}": "ParagraphNext",
|
2017-03-01 17:30:35 +03:00
|
|
|
"Enter": "InsertNewline",
|
|
|
|
"CtrlH": "Backspace",
|
|
|
|
"Backspace": "Backspace",
|
|
|
|
"Alt-CtrlH": "DeleteWordLeft",
|
|
|
|
"Alt-Backspace": "DeleteWordLeft",
|
|
|
|
"Tab": "IndentSelection,InsertTab",
|
2017-06-18 00:36:27 +03:00
|
|
|
"Backtab": "OutdentSelection,OutdentLine",
|
2017-03-01 17:30:35 +03:00
|
|
|
"CtrlO": "OpenFile",
|
|
|
|
"CtrlS": "Save",
|
|
|
|
"CtrlF": "Find",
|
|
|
|
"CtrlN": "FindNext",
|
|
|
|
"CtrlP": "FindPrevious",
|
|
|
|
"CtrlZ": "Undo",
|
|
|
|
"CtrlY": "Redo",
|
|
|
|
"CtrlC": "Copy",
|
|
|
|
"CtrlX": "Cut",
|
|
|
|
"CtrlK": "CutLine",
|
|
|
|
"CtrlD": "DuplicateLine",
|
|
|
|
"CtrlV": "Paste",
|
|
|
|
"CtrlA": "SelectAll",
|
|
|
|
"CtrlT": "AddTab",
|
|
|
|
"Alt,": "PreviousTab",
|
|
|
|
"Alt.": "NextTab",
|
|
|
|
"Home": "StartOfLine",
|
|
|
|
"End": "EndOfLine",
|
|
|
|
"CtrlHome": "CursorStart",
|
|
|
|
"CtrlEnd": "CursorEnd",
|
|
|
|
"PageUp": "CursorPageUp",
|
|
|
|
"PageDown": "CursorPageDown",
|
|
|
|
"CtrlG": "ToggleHelp",
|
|
|
|
"CtrlR": "ToggleRuler",
|
|
|
|
"CtrlL": "JumpLine",
|
|
|
|
"Delete": "Delete",
|
|
|
|
"CtrlB": "ShellMode",
|
|
|
|
"CtrlQ": "Quit",
|
|
|
|
"CtrlE": "CommandMode",
|
|
|
|
"CtrlW": "NextSplit",
|
|
|
|
"CtrlU": "ToggleMacro",
|
|
|
|
"CtrlJ": "PlayMacro",
|
|
|
|
|
|
|
|
// Emacs-style keybindings
|
|
|
|
"Alt-f": "WordRight",
|
|
|
|
"Alt-b": "WordLeft",
|
|
|
|
"Alt-a": "StartOfLine",
|
|
|
|
"Alt-e": "EndOfLine",
|
|
|
|
|
|
|
|
// Integration with file managers
|
|
|
|
"F1": "ToggleHelp",
|
|
|
|
"F2": "Save",
|
|
|
|
"F3": "Find",
|
|
|
|
"F4": "Quit",
|
|
|
|
"F7": "Find",
|
|
|
|
"F10": "Quit",
|
|
|
|
"Esc": "Escape",
|
2017-06-18 00:36:27 +03:00
|
|
|
|
|
|
|
// Mouse bindings
|
|
|
|
"MouseWheelUp": "ScrollUp",
|
|
|
|
"MouseWheelDown": "ScrollDown",
|
|
|
|
"MouseLeft": "MousePress",
|
|
|
|
"MouseMiddle": "PastePrimary",
|
|
|
|
"Ctrl-MouseLeft": "MouseMultiCursor",
|
|
|
|
|
|
|
|
// Multiple cursors bindings
|
|
|
|
"Alt-n": "SpawnMultiCursor",
|
|
|
|
"Alt-p": "RemoveMultiCursor",
|
|
|
|
"Alt-c": "RemoveAllMultiCursors",
|
|
|
|
"Alt-x": "SkipMultiCursor",
|
2017-03-01 17:30:35 +03:00
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2017-10-11 16:16:53 +03:00
|
|
|
## Final notes
|
|
|
|
|
|
|
|
Note: On some old terminal emulators and on Windows machines, `CtrlH` should be
|
|
|
|
used for backspace.
|
2016-09-26 16:34:55 +03:00
|
|
|
|
2017-10-11 16:16:53 +03:00
|
|
|
Additionally, alt keys can be bound by using `Alt-key`. For example `Alt-a` or
|
|
|
|
`Alt-Up`. Micro supports an optional `-` between modifiers like `Alt` and
|
2017-10-07 03:42:58 +03:00
|
|
|
`Ctrl` so `Alt-a` could be rewritten as `Alta` (case matters for alt bindings).
|
|
|
|
This is why in the default keybindings you can see `AltShiftLeft` instead of
|
|
|
|
`Alt-ShiftLeft` (they are equivalent).
|