3 This is a brief intro to micro's configuration system that will will give some
4 simple examples showing how to configure settings, rebind keys,
5 and use `init.lua` to configure micro to your liking.
7 Hopefully you'll find this useful.
11 In micro, your settings are stored in `~/.config/micro/settings.json`, a file
12 that is created the first time you run micro. It is a json file which holds
13 all the settings and their values. To change an option, you can either
14 change the value in the `settings.json` file, or you can type it in directly
17 Simply press CtrlE to go to command mode, and type `set option value` (in the
18 future, I will use `> set option value` to indicate pressing CtrlE). The
19 change will take effect immediately and will also be saved to the `settings.json`
20 file so that the setting will stick even after you close micro.
22 You can also set options locally which means that the setting will only have
23 the value you give it in the buffer you set it in. For example, if you have
24 two splits open, and you type `> setlocal tabsize 2`, the tabsize will only
25 be 2 in the current buffer. Also micro will not save this local change to the
26 `settings.json` file. However, you can still set options locally in the
27 `settings.json` file. For example, if you want the `tabsize` to be 2 only
28 in Ruby files, and 4 otherwise, you could put the following in `settings.json`:
39 Micro will set the `tabsize` to 2 only in files which match the glob `*.rb`.
41 If you would like to know more about all the available options, see the
42 `options` topic (`> help options`).
46 Keybindings work in much the same way as options. You configure them using
47 the `~/.config/micro/bindings.json` file.
49 For example if you would like to bind `CtrlR` to redo you could put the
50 following in `bindings.json`:
60 You can also bind keys while in micro by using the `> bind key action` command,
61 but the bindings you make with the command won't be saved to the `bindings.json`
64 For more information about keybindings, like which keys can be bound, and
65 what actions are available, see the `keybindings` help topic (`> help keybindings`).
67 ### Configuration with Lua
69 If you need more power than the json files provide, you can use the `init.lua`
70 file. Create it in `~/.config/micro`. This file is a lua file that is run
71 when micro starts and is essential a one-file plugin.
73 I'll show you how to use the `init.lua` file by giving an example of how to
74 create a binding to `CtrlR` which will execute `go run` on the current file,
75 given that the current file is a Go file.
77 You can do that by putting the following in `init.lua`:
81 local buf = CurView().Buf -- The current buffer
82 if buf:FileType() == "go" then
83 HandleShellCommand("go run " .. buf.Path, true) -- true means don't run it in the background
87 BindKey("CtrlR", "init.gorun")
90 Alternatively, you could get rid of the `BindKey` line, and put this line in
91 the `bindings.json` file:
99 For more information about plugins and the lua system that micro uses, see
100 the `plugins` help topic (`> help plugins`).