2.9 KiB
title | date | description |
---|---|---|
Micro Editor | 2021-04-06 | Editing code in a shell without going insane with Micro. |
There's a couple of options available when it comes to editing code on a tilde like South London. The first ones that come to mind are probably nano
, vim
/vi
/neovim
and emacs
. I usually end up using vim
or nano
if I have something quick to edit like a config file, but editing whole scripts and things is where they start to be a bit frustrating. Micro is an excellent editor that you can install quickly and makes your life a lot easier with mouse support and sane keyboard shortcuts.
Install
Firstly, we need somewhere to install Micro, so lets make a folder at ~/.local/bin
.
mkdir -p ~/.local/bin
cd ~/.local/bin
Now lets run the install script. You should inspect the contents before running by just leaving the bash
command off the end.
curl https://getmic.ro | bash
The installer script should automatically detect your architecture and operating system and download the relavent version to the folder that you are in.
Finally, we need to tell our shell that we have programs installed in ~/.local/bin
that we want to use. We can do that by adding the following line to the bottom of the ~/.bashrc
file.
# other things...
export PATH="${PATH}:~/.local/bin"
Usage
Now that we've got Micro installed, simply run micro
with a filename to open a file.
micro ~/public_html/index.html
You have the regular keyboard shortcuts you'd expect like CTRL + O and CTRL + S for open and save respectively.
You can use CTRL + E to run editor commands like these useful ones:
help
: get help on how to use the editoropen /path/to/file
: open a filesave
: save the opened filevsplit /path/to/file
: split the editor vertically, opening the given file in the new split (CTRL + W to switch between splits, CTRL + Q to close the split)hsplit /path/to/file
: same as a vertical split, but you guessed it, horizontal insteadset <option> <value>
: configure the editor, see below for some useful options
Useful options
set clipboard internal
: this either needs to be set toterminal
orinternal
as we'll be using Micro over SSH, otherwise if you installed it on your local computer, you'd set this toexternal
.internal
just keeps the copy and paste buffer inside the editor rather than copying to your system clipboard which I found a bit janky withterminal
set colorscheme darcula
: this sets the theme that is used for syntax highlighting. Use the commandhelp colors
to see the other themes that are availableset diffgutter true
: this shows a little colour indicator on the line number gutter to whether you have added/updated/removed lines, useful for if you are working with git.