**micro**is a terminal-based text editor that aims to be easy to use and intuitive, while also taking advantage of the capabilities of modern terminals. It comes as a single, batteries-included, static binary with no dependencies; you can download and use it right now!
As its name indicates, micro aims to be somewhat of a successor to the nano editor by being easy to install and use. It strives to be enjoyable as a full-time editor for people who prefer to work in a terminal, or those who regularly edit files over [SSH](../network/SSH.md).
Micro has a plethora of hotkeys that make it easy and powerful to use and all hotkeys are fully customizable to your liking.
Custom keybindings are stored internally in micro if changed with the > bind command or can also be added in the file `~/.config/micro/bindings.json`
### Rebinding keys
The bindings may be rebound using the `~/.config/micro/bindings.json` file. Each key is bound to an action.
For example, to bind Ctrl-y to undo and Ctrl-z to redo, you could put the following in the bindings.json file.
```json
{
"Ctrl-y": "Undo",
"Ctrl-z": "Redo"
}
```
### 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"
}
```
### Bindables
Actions:
```
CursorUp
CursorDown
CursorPageUp
CursorPageDown
CursorLeft
CursorRight
CursorStart
CursorEnd
SelectToStart
SelectToEnd
SelectUp
SelectDown
SelectLeft
SelectRight
SelectToStartOfText
SelectToStartOfTextToggle
WordRight
WordLeft
SelectWordRight
SelectWordLeft
MoveLinesUp
MoveLinesDown
DeleteWordRight
DeleteWordLeft
SelectLine
SelectToStartOfLine
SelectToEndOfLine
InsertNewline
InsertSpace
Backspace
Delete
Center
InsertTab
Save
SaveAll
SaveAs
Find
FindLiteral
FindNext
FindPrevious
DiffPrevious
DiffNext
Undo
Redo
Copy
CopyLine
Cut
CutLine
DuplicateLine
DeleteLine
IndentSelection
OutdentSelection
OutdentLine
IndentLine
Paste
SelectAll
OpenFile
Start
End
PageUp
PageDown
SelectPageUp
SelectPageDown
HalfPageUp
HalfPageDown
StartOfLine
EndOfLine
StartOfText
StartOfTextToggle
ParagraphPrevious
ParagraphNext
ToggleHelp
ToggleDiffGutter
ToggleRuler
JumpLine
ClearStatus
ShellMode
CommandMode
Quit
QuitAll
AddTab
PreviousTab
NextTab
NextSplit
Unsplit
VSplit
HSplit
PreviousSplit
ToggleMacro
PlayMacro
Suspend (Unix only)
ScrollUp
ScrollDown
SpawnMultiCursor
SpawnMultiCursorUp
SpawnMultiCursorDown
SpawnMultiCursorSelect
RemoveMultiCursor
RemoveAllMultiCursors
SkipMultiCursor
None
JumpToMatchingBrace
Autocomplete
```
Keys:
```
Up
Down
Right
Left
UpLeft
UpRight
DownLeft
DownRight
Center
PageUp
PageDown
Home
End
Insert
Delete
Help
Exit
Clear
Cancel
Print
Pause
Backtab
F1
F2
F3
F4
F5
F6
F7
F8
F9
F10
F11
F12
F13
F14
F15
F16
F17
F18
F19
F20
F21
F22
F23
F24
F25
F26
F27
F28
F29
F30
F31
F32
F33
F34
F35
F36
F37
F38
F39
F40
F41
F42
F43
F44
F45
F46
F47
F48
F49
F50
F51
F52
F53
F54
F55
F56
F57
F58
F59
F60
F61
F62
F63
F64
CtrlSpace
Ctrl-a
Ctrl-b
Ctrl-c
Ctrl-d
Ctrl-e
Ctrl-f
Ctrl-g
Ctrl-h
Ctrl-i
Ctrl-j
Ctrl-k
Ctrl-l
Ctrl-m
Ctrl-n
Ctrl-o
Ctrl-p
Ctrl-q
Ctrl-r
Ctrl-s
Ctrl-t
Ctrl-u
Ctrl-v
Ctrl-w
Ctrl-x
Ctrl-y
Ctrl-z
CtrlLeftSq
CtrlBackslash
CtrlRightSq
CtrlCarat
CtrlUnderscore
Backspace
OldBackspace
Tab
Esc
Escape
Enter
```
Mouse
```
MouseLeft
MouseMiddle
MouseRight
MouseWheelUp
MouseWheelDown
MouseWheelLeft
MouseWheelRight
```
# Commands
Micro provides the following commands that can be executed at the command-bar by pressing`Ctrl-e`and entering the command. Arguments are placed in single quotes here but these are not necessary when entering the command in micro.
-`bind 'key' 'action'`: creates a keybinding from key to action. See the`keybindings`documentation for more information about binding keys. This command will modify`bindings.json`and overwrite any bindings to`key`that already exist.
-`help 'topic'?`: opens the corresponding help topic. If no topic is provided opens the default help screen. Help topics are stored as`.md`files in the`runtime/help`directory of the source tree, which is embedded in the final binary.
-`save 'filename'?`: saves the current buffer. If the file is provided it will 'save as' the filename.
-`quit`: quits micro.
-`goto 'line'`: jumps to the given line number. A negative number can be passed to jump inward from the end of the file; for example, -5 jumps to the 5th-last line in the file.
-`replace 'search' 'value' 'flags'?`: This will replace`search`with`value`. The`flags`are optional. Possible flags are:
-`-a`: Replace all occurrences at once
-`-l`: Do a literal search instead of a [regex](../../tools/Regex.md) search
Note that`search`must be a valid [regex](../../tools/Regex.md) (unless`-l`is passed). If one of the arguments does not have any spaces in it, you may omit the quotes.
-`replaceall 'search' 'value'`: this will replace all occurrences of`search`with`value`without user confirmation.
See`replace`command for more information.
-`set 'option' 'value'`: sets the option to value. See the`options`help topic for a list of options you can set. This will modify your`settings.json`with the new value.
-`setlocal 'option' 'value'`: sets the option to value locally (only in the current buffer). This will_not_modify`settings.json`.
-`show 'option'`: shows the current value of the given option.
-`run 'sh-command'`: runs the given [shell](Shell.md) command in the background. The command's output will be displayed in one line when it finishes running.
-`vsplit 'filename'`: opens a vertical split with`filename`. If no filename is provided, a vertical split is opened with an empty buffer.
-`hsplit 'filename'`: same as`vsplit`but opens a horizontal split instead of a vertical split.
-`tab 'filename'`: opens the given file in a new tab.
-`tabmove '[-+]?n'`: Moves the active tab to another slot.`n`is an integer. If`n`is prefixed with`-`or`+`, then it represents a relative position (e.g.`tabmove +2`moves the tab to the right by`2`). If`n`has no prefix, it represents an absolute position (e.g.`tabmove 2`moves the tab to slot`2`).
-`tabswitch 'tab'`: This command will switch to the specified tab. The`tab`can either be a tab number, or a name of a tab.
-`textfilter 'sh-command'`: filters the current selection through a [shell](Shell.md) command as standard input and replaces the selection with the stdout of the [shell](Shell.md) command. For example, to sort a list of numbers, first select them, and then execute`> textfilter sort -n`.
-`log`: opens a log of all messages and debug statements.
-`plugin list`: lists all installed plugins.
-`plugin install 'pl'`: install a plugin.
-`plugin remove 'pl'`: remove a plugin.
-`plugin update 'pl'`: update a plugin (if no arguments are provided updates all plugins).
-`plugin search 'pl'`: search available plugins for a keyword.
-`plugin available`: show available plugins that can be installed.
-`reload`: reloads all runtime files.
-`cd 'path'`: Change the working directory to the given`path`.
-`pwd`: Print the current working directory.
-`open 'filename'`: Open a file in the current buffer.
-`reset 'option'`: resets the given option to its default value
-`retab`: Replaces all leading tabs with spaces or leading spaces with tabs depending on the value of`tabstospaces`.
-`raw`: micro will open a new tab and show the escape sequence for every event it receives from the terminal. This shows you what micro actually sees from the terminal and helps you see which bindings aren't possible and why. This is most useful for debugging keybindings.
-`showkey`: Show the action(s) bound to a given key. For example running`> showkey Ctrl-c`will display`Copy`.
-`term exec?`: Open a terminal emulator running the given executable. If no executable is given, this will open the default [shell](Shell.md) in the terminal emulator.
## Settings
Micro stores all of the user configuration in its configuration directory.
Micro uses `$MICRO_CONFIG_HOME` as the configuration directory. If this
environment variable is not set, it uses `$XDG_CONFIG_HOME/micro` instead. If
that environment variable is not set, it uses `~/.config/micro` as the
configuration directory. In the documentation, we use `~/.config/micro` to
refer to the configuration directory (even if it may in fact be somewhere else
if you have set either of the above environment variables). Settings are stored in `settings.json`
Here are the available options:
*`autoindent`: when creating a new line, use the same indentation as the
previous line.
default value: `true`
*`autosave`: automatically save the buffer every n seconds, where n is the
value of the autosave option. Also when quitting on a modified buffer, micro
will automatically save and quit. Be warned, this option saves the buffer
without prompting the user, so data may be overwritten. If this option is
set to `0`, no autosaving is performed.
default value: `0`
*`autosu`: When a file is saved that the user doesn't have permission to
modify, micro will ask if the user would like to use super user
privileges to save the file. If this option is enabled, micro will
automatically attempt to use super user privileges to save without
asking the user.
default value: `false`
*`backup`: micro will automatically keep backups of all open buffers. Backups
are stored in `~/.config/micro/backups` and are removed when the buffer is
closed cleanly. In the case of a system crash or a micro crash, the contents
of the buffer can be recovered automatically by opening the file that was
being edited before the crash, or manually by searching for the backup in
the backup directory. Backups are made in the background for newly modified
buffers every 8 seconds, or when micro detects a crash.
default value: `true`
*`backupdir`: the directory micro should place backups in. For the default
value of `""` (empty string), the backup directory will be
`ConfigDir/backups`, which is `~/.config/micro/backups` by default. The
directory specified for backups will be created if it does not exist.
default value: `""` (empty string)
*`basename`: in the infobar and tabbar, show only the basename of the file
being edited rather than the full path.
default value: `false`
*`clipboard`: specifies how micro should access the system clipboard.
Possible values are:
*`external`: accesses clipboard via an external tool, such as xclip/xsel
or wl-clipboard on [Linux](../../linux/Linux.md), pbcopy/pbpaste on [MacOS](../../macos/macOS.md), and system calls on
[Windows](../../windows/Windows.md). On Linux, if you do not have one of the tools installed, or if
they are not working, micro will throw an error and use an internal
clipboard.
*`terminal`: accesses the clipboard via your terminal emulator. Note that
there is limited support among terminal emulators for this feature
(called OSC 52). Terminals that are known to work are Kitty (enable
reading with `clipboard_control` setting), iTerm2 (only copying),
st, rxvt-unicode and xterm if enabled (see `> help copypaste` for
details). Note that Gnome-terminal does not support this feature. With