]> git.lizzy.rs Git - micro.git/blob - runtime/help/commands.md
Clarified some documentation (#2259)
[micro.git] / runtime / help / commands.md
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'?`: opens the corresponding help topic. If no topic is provided
25    opens the default help screen. Help topics are stored as `.md` files in the
26    `runtime/help` directory of the source tree, which is embedded in the final
27    binary.
28
29 * `save 'filename'?`: saves the current buffer. If the file is provided it
30    will 'save as' the filename.
31
32 * `quit`: quits micro.
33
34 * `goto 'line'`: jumps to the given line number. A negative number can be
35    passed to jump inward from the end of the file; for example, -5 jumps
36    to the 5th-last line in the file.
37
38 * `replace 'search' 'value' 'flags'?`: This will replace `search` with `value`. 
39    The `flags` are optional. Possible flags are:
40    * `-a`: Replace all occurrences at once
41    * `-l`: Do a literal search instead of a regex search
42
43    Note that `search` must be a valid regex (unless `-l` is passed). If one 
44    of the arguments does not have any spaces in it, you may omit the quotes.
45
46 * `replaceall 'search' 'value'`: this will replace all occurrences of `search`
47    with `value` without user confirmation.
48
49         See `replace` command for more information.
50
51 * `set 'option' 'value'`: sets the option to value. See the `options` help
52    topic for a list of options you can set. This will modify your
53    `settings.json` with the new value.
54
55 * `setlocal 'option' 'value'`: sets the option to value locally (only in the
56    current buffer). This will *not* modify `settings.json`.
57
58 * `show 'option'`: shows the current value of the given option.
59
60 * `run 'sh-command'`: runs the given shell command in the background. The 
61    command's output will be displayed in one line when it finishes running.
62
63 * `vsplit 'filename'`: opens a vertical split with `filename`. If no filename
64    is provided, a vertical split is opened with an empty buffer.
65
66 * `hsplit 'filename'`: same as `vsplit` but opens a horizontal split instead
67    of a vertical split.
68
69 * `tab 'filename'`: opens the given file in a new tab.
70
71 * `tabmove '[-+]?n'`: Moves the active tab to another slot. `n` is an integer.
72    If `n` is prefixed with `-` or `+`, then it represents a relative position
73    (e.g. `tabmove +2` moves the tab to the right by `2`). If `n` has no prefix,
74    it represents an absolute position (e.g. `tabmove 2` moves the tab to slot `2`).
75
76 * `tabswitch 'tab'`: This command will switch to the specified tab. The `tab`
77    can either be a tab number, or a name of a tab.
78
79 * `textfilter 'sh-command'`: filters the current selection through a shell
80    command as standard input and replaces the selection with the stdout of
81    the shell command.  For example, to sort a list of numbers, first select
82    them, and then execute `> textfilter sort -n`.
83
84 * `log`: opens a log of all messages and debug statements.
85
86 * `plugin list`: lists all installed plugins.
87
88 * `plugin install 'pl'`: install a plugin.
89
90 * `plugin remove 'pl'`: remove a plugin.
91
92 * `plugin update 'pl'`: update a plugin (if no arguments are provided
93    updates all plugins).
94
95 * `plugin search 'pl'`: search available plugins for a keyword.
96
97 * `plugin available`: show available plugins that can be installed.
98
99 * `reload`: reloads all runtime files.
100
101 * `cd 'path'`: Change the working directory to the given `path`.
102
103 * `pwd`: Print the current working directory.
104
105 * `open 'filename'`: Open a file in the current buffer.
106
107 * `reset 'option'`: resets the given option to its default value
108
109 * `retab`: Replaces all leading tabs with spaces or leading spaces with tabs
110    depending on the value of `tabstospaces`.
111
112 * `raw`: micro will open a new tab and show the escape sequence for every event
113    it receives from the terminal. This shows you what micro actually sees from
114    the terminal and helps you see which bindings aren't possible and why. This
115    is most useful for debugging keybindings.
116
117 * `showkey`: Show the action(s) bound to a given key. For example
118    running `> showkey Ctrl-c` will display `Copy`.
119
120 * `term exec?`: Open a terminal emulator running the given executable. If no
121    executable is given, this will open the default shell in the terminal
122    emulator.
123
124 ---
125
126 The following commands are provided by the default plugins:
127
128 * `lint`: Lint the current file for errors.
129 * `comment`: automatically comment or uncomment current selection or line.