| 1 |
# Command bar |
| 2 |
|
| 3 |
The command bar is opened by pressing `Ctrl-e`. It is a single-line buffer, |
| 4 |
meaning that all keybindings from a normal buffer are supported (as well |
| 5 |
as mouse and selection). |
| 6 |
|
| 7 |
When running a command, you can use extra syntax that micro will expand before |
| 8 |
running the command. To use an argument with a space in it, put it in |
| 9 |
quotes. The command bar parser uses the same rules for parsing arguments that |
| 10 |
`/bin/sh` would use (single quotes, double quotes, escaping). The command bar |
| 11 |
does not look up environment variables. |
| 12 |
|
| 13 |
# Commands |
| 14 |
|
| 15 |
Micro provides the following commands that can be executed at the command-bar |
| 16 |
by pressing `Ctrl-e` and entering the command. Arguments are placed in single |
| 17 |
quotes here but these are not necessary when entering the command in micro. |
| 18 |
|
| 19 |
* `bind 'key' 'action'`: creates a keybinding from key to action. See the |
| 20 |
`keybindings` documentation for more information about binding keys. |
| 21 |
This command will modify `bindings.json` and overwrite any bindings to |
| 22 |
`key` that already exist. |
| 23 |
|
| 24 |
* `help ['topic'] ['flags']`: opens the corresponding help topics. |
| 25 |
If no topic is provided opens the default help screen. If multiple topics are |
| 26 |
provided (separated via ` `) they are opened all as splits. |
| 27 |
Help topics are stored as `.md` files in the `runtime/help` directory of |
| 28 |
the source tree, which is embedded in the final binary. |
| 29 |
The `flags` are optional. |
| 30 |
* `-hsplit`: Opens the help topic in a horizontal split |
| 31 |
* `-vsplit`: Opens the help topic in a vertical split |
| 32 |
|
| 33 |
The default split type is defined by the global `helpsplit` option. |
| 34 |
|
| 35 |
* `save ['filename']`: saves the current buffer. If the file is provided it |
| 36 |
will 'save as' the filename. |
| 37 |
|
| 38 |
* `quit`: quits micro. |
| 39 |
|
| 40 |
* `goto 'line[:col]'`: goes to the given absolute line (and optional column) |
| 41 |
number. |
| 42 |
A negative number can be passed to go inward from the end of the file. |
| 43 |
Example: -5 goes to the 5th-last line in the file. |
| 44 |
|
| 45 |
* `jump 'line[:col]'`: goes to the given relative number from the current |
| 46 |
line (and optional absolute column) number. |
| 47 |
Example: -5 jumps 5 lines up in the file, while (+)3 jumps 3 lines down. |
| 48 |
|
| 49 |
* `replace 'search' 'value' ['flags']`: This will replace `search` with `value`. |
| 50 |
The `flags` are optional. Possible flags are: |
| 51 |
* `-a`: Replace all occurrences at once |
| 52 |
* `-l`: Do a literal search instead of a regex search |
| 53 |
|
| 54 |
Note that `search` must be a valid regex (unless `-l` is passed). If one |
| 55 |
of the arguments does not have any spaces in it, you may omit the quotes. |
| 56 |
|
| 57 |
In case the search is done non-literal (without `-l`), the 'value' |
| 58 |
is interpreted as a template: |
| 59 |
* `$3` or `${3}` substitutes the submatch of the 3rd (capturing group) |
| 60 |
* `$foo` or `${foo}` substitutes the submatch of the (?P<foo>named group) |
| 61 |
* You have to write `$$` to substitute a literal dollar. |
| 62 |
|
| 63 |
* `replaceall 'search' 'value'`: this will replace all occurrences of `search` |
| 64 |
with `value` without user confirmation. |
| 65 |
|
| 66 |
See `replace` command for more information. |
| 67 |
|
| 68 |
* `set 'option' 'value'`: sets the option to value. See the `options` help |
| 69 |
topic for a list of options you can set. This will modify your |
| 70 |
`settings.json` with the new value. |
| 71 |
|
| 72 |
* `setlocal 'option' 'value'`: sets the option to value locally (only in the |
| 73 |
current buffer). This will *not* modify `settings.json`. |
| 74 |
|
| 75 |
* `toggle 'option'`: toggles the option. Only works with options that accept |
| 76 |
exactly two values. This will modify your `settings.json` with the new value. |
| 77 |
|
| 78 |
* `togglelocal 'option'`: toggles the option locally (only in the |
| 79 |
current buffer). Only works with options that accept exactly two values. |
| 80 |
This will *not* modify `settings.json`. |
| 81 |
|
| 82 |
* `reset 'option'`: resets the given option to its default value. |
| 83 |
|
| 84 |
* `show 'option'`: shows the current value of the given option. |
| 85 |
|
| 86 |
* `showkey 'key'`: Show the action(s) bound to a given key. For example |
| 87 |
running `> showkey Ctrl-c` will display `Copy`. |
| 88 |
|
| 89 |
* `run 'sh-command'`: runs the given shell command in the background. The |
| 90 |
command's output will be displayed in one line when it finishes running. |
| 91 |
|
| 92 |
* `vsplit ['filename']`: opens a vertical split with `filename`. If no filename |
| 93 |
is provided, a vertical split is opened with an empty buffer. If multiple |
| 94 |
files are provided (separated via ` `) they are opened all as splits. |
| 95 |
|
| 96 |
* `hsplit ['filename']`: same as `vsplit` but opens a horizontal split instead |
| 97 |
of a vertical split. |
| 98 |
|
| 99 |
* `tab ['filename']`: opens the given file in a new tab. If no filename |
| 100 |
is provided, a tab is opened with an empty buffer. If multiple files are |
| 101 |
provided (separated via ` `) they are opened all as tabs. |
| 102 |
|
| 103 |
* `tabmove '[-+]n'`: Moves the active tab to another slot. `n` is an integer. |
| 104 |
If `n` is prefixed with `-` or `+`, then it represents a relative position |
| 105 |
(e.g. `tabmove +2` moves the tab to the right by `2`). If `n` has no prefix, |
| 106 |
it represents an absolute position (e.g. `tabmove 2` moves the tab to slot `2`). |
| 107 |
|
| 108 |
* `tabswitch 'tab'`: This command will switch to the specified tab. The `tab` |
| 109 |
can either be a tab number, or a name of a tab. |
| 110 |
|
| 111 |
* `textfilter 'sh-command'`: filters the current selection through a shell |
| 112 |
command as standard input and replaces the selection with the stdout of |
| 113 |
the shell command. For example, to sort a list of numbers, first select |
| 114 |
them, and then execute `> textfilter sort -n`. |
| 115 |
|
| 116 |
* `log`: opens a log of all messages and debug statements. |
| 117 |
|
| 118 |
* `plugin list`: lists all installed plugins. |
| 119 |
|
| 120 |
* `plugin install 'pl'`: install a plugin. |
| 121 |
|
| 122 |
* `plugin remove 'pl'`: remove a plugin. |
| 123 |
|
| 124 |
* `plugin update ['pl']`: update a plugin (if no arguments are provided |
| 125 |
updates all plugins). |
| 126 |
|
| 127 |
* `plugin search 'pl'`: search available plugins for a keyword. |
| 128 |
|
| 129 |
* `plugin available`: show available plugins that can be installed. |
| 130 |
|
| 131 |
* `reload`: reloads all runtime files (settings, keybindings, syntax files, |
| 132 |
colorschemes, plugins). All plugins will be unloaded by running their |
| 133 |
`deinit()` function (if it exists), and then loaded again by calling the |
| 134 |
`preinit()`, `init()` and `postinit()` functions (if they exist). |
| 135 |
|
| 136 |
* `cd 'path'`: Change the working directory to the given `path`. |
| 137 |
|
| 138 |
* `pwd`: Print the current working directory. |
| 139 |
|
| 140 |
* `open 'filename'`: Open a file in the current buffer. |
| 141 |
|
| 142 |
* `reopen`: Reopens the current file from disk. |
| 143 |
|
| 144 |
* `retab`: Replaces all leading tabs with spaces or leading spaces with tabs |
| 145 |
depending on the value of `tabstospaces`. |
| 146 |
|
| 147 |
* `raw`: micro will open a new tab and show the escape sequence for every event |
| 148 |
it receives from the terminal. This shows you what micro actually sees from |
| 149 |
the terminal and helps you see which bindings aren't possible and why. This |
| 150 |
is most useful for debugging keybindings. |
| 151 |
|
| 152 |
* `term ['exec']`: Open a terminal emulator running the given executable. If no |
| 153 |
executable is given, this will open the default shell in the terminal |
| 154 |
emulator. |
| 155 |
|
| 156 |
--- |
| 157 |
|
| 158 |
The following commands are provided by the default plugins: |
| 159 |
|
| 160 |
* `lint`: Lint the current file for errors. |
| 161 |
* `comment`: automatically comment or uncomment current selection or line. |