]> git.lizzy.rs Git - micro.git/blob - runtime/help/commands.md
Merge pull request #1194 from MJBrune/patch-1
[micro.git] / runtime / help / commands.md
1 # Possible commands
2
3 You can execute an editor command by pressing `Ctrl-e` followed by the command.
4 Here are the possible commands that you can use.
5
6 * `quit`: Quits micro.
7
8 * `save filename?`: Saves the current buffer. If the filename is provided it
9   will 'save as' the filename.
10
11 * `replace "search" "value" flags`: This will replace `search` with `value`. 
12    The `flags` are optional. Possible flags are:
13    * `-a`: Replace all occurrences at once
14    * `-l`: Do a literal search instead of a regex search
15
16    Note that `search` must be a valid regex (unless `-l` is passed). If one 
17    of the arguments does not have any spaces in it, you may omit the quotes.
18
19 * `replaceall "search" "value"`: This will replace `search` with `value` without
20    user confirmation.
21
22         See `replace` command for more information.
23
24 * `set option value`: sets the option to value. See the `options` help topic for
25    a list of options you can set.
26
27 * `setlocal option value`: sets the option to value locally (only in the current
28    buffer).
29
30 * `show option`: shows the current value of the given option.
31
32 * `eval "expression"`: Evaluates a Lua expression. Note that micro will not
33    print anything so you should use `messenger:Message(...)` to display a value.
34
35 * `run sh-command`: runs the given shell command in the background. The 
36    command's output will be displayed in one line when it finishes running.
37
38 * `bind key action`: creates a keybinding from key to action. See the sections
39    on keybindings above for more info about what keys and actions are available.
40
41 * `vsplit filename`: opens a vertical split with `filename`. If no filename is
42    provided, a vertical split is opened with an empty buffer.
43
44 * `hsplit filename`: same as `vsplit` but opens a horizontal split instead of a
45    vertical split.
46
47 * `tab filename`: opens the given file in a new tab.
48
49 * `tabswitch tab`: This command will switch to the specified tab. The `tab` can
50    either be a tab number, or a name of a tab.
51                                          
52 * `log`: opens a log of all messages and debug statements.
53
54 * `plugin install plugin_name`: installs the given plugin.
55
56 * `plugin remove plugin_name`: removes the given plugin.
57
58 * `plugin list`: lists all installed plugins.
59
60 * `plugin update`: updates all installed plugins.
61
62 * `plugin search plugin_name`: searches for the given plugin. Note that you can
63    find a list of all available plugins at
64    github.com/micro-editor/plugin-channel.
65
66    You can also see more information about the plugin manager in the
67    `Plugin Manager` section of the `plugins` help topic.
68
69 * `plugin available`: list plugins available for download (this includes any
70    plugins that may be already installed).
71
72 * `reload`: reloads all runtime files.
73
74 * `cd path`: Change the working directory to the given `path`.
75
76 * `pwd`: Print the current working directory.
77
78 * `open filename`: Open a file in the current buffer.
79
80 * `retab`: Replaces all leading tabs with spaces or leading spaces with tabs
81    depending on the value of `tabstospaces`.
82
83 * `raw`: Micro will open a new tab and show the escape sequence for every event
84    it receives from the terminal. This shows you what micro actually sees from
85    the terminal and helps you see which bindings aren't possible and why. This
86    is most useful for debugging keybindings.
87
88 * `showkey`: Show the action(s) bound to a given key. For example
89    running `> showkey CtrlC` will display `main.(*View).Copy`. Unfortuately
90    showkey does not work well for keys bound to plugin actions. For those
91    it just shows "LuaFunctionBinding."
92
93 ---
94
95 The following commands are provided by the default plugins:
96
97 * `lint`: Lint the current file for errors.
98
99 # Command Parsing
100
101 When running a command, you can use extra syntax that micro will expand before
102 running the command. To use an argument with a space in it, simply put it in
103 quotes. You can also use environment variables in the command bar and they
104 will be expanded to their value. Finally, you can put an expression in backticks
105 and it will be evaluated by the shell beforehand.