I prefer command-line editors over full-blown IDEs. For my upcoming Kotlin projects, I decided to try out IntelliJ IDEA and VSCode (in the form of VSCodium and https://vscode.dev). Although I was pleasantly surprised by IntelliJ IDEA’s distraction-free mode. I still prefer command-line editors. To my knowledge: people who use command-line editors aren't fond of debugging tools, and that's where IDE's have the edge. I should look more into utilizing debug tools later.
The most important thing for me are keyboard shortcuts because I’m too lazy to keep clicking and dragging buttons around. Although I still use vi(m) sometimes, I think modal editing is a bit overrated. However, it doesn’t stop me from using other software with vim keys; Firefox+viumium and lf come to mind.
There are plenty of CLI editors out in the wild; most of them are way older than micro so UTF-8 isn’t a promise. I suggest trying out elvis, mcedit, mg, nano, and vile.
My favorite things about micro are its super small size of the editor, working clipboard, mostly sensible keybindings, and excellent language support. I might expand the list in the future if there are other hurdles in my way.
Get alt, ctrl & shift keys working correctly within tmux
I love tmux to bits, but if you open micro inside tmux, modifier keys aren't working properly. Instead of highlighting the text it print's out [1;2D] [1;2C]... and a bunch of other junk we wouldn't want in our text.
Stackoverflow to the rescue! Author of micro found a fix for that by inserting the following into ~/.config/micro/bindings.json
"\u001b[1;2A": "SelectUp",
"\u001b[1;2B": "SelectDown",
"\u001b[1;2C": "SelectRight",
"\u001b[1;2D": "SelectLeft",
"\u001b[1;3D": "WordLeft",
"\u001b[1;3C": "WordRight",
"\u001b[1;3A": "MoveLinesUp",
"\u001b[1;3B": "MoveLinesDown",
"\u001b[1;4C": "SelectWordRight",
"\u001b[1;4D": "SelectWordLeft",
"\u001b[1;5D": "StartOfLine",
"\u001b[1;5C": "EndOfLine",
"\u001b[1;6D": "SelectToStartOfLine",
"\u001b[1;6C": "SelectToEndOfLine",
"\u001b[1;5A": "CursorStart",
"\u001b[1;5B": "CursorEnd",
"\u001b[1;6A": "SelectToStart",
"\u001b[1;6B": "SelectToEnd"
I'm leaving link's to stackoverflow thread in the end.
Bind Ctrl-R and Alt-R to replaceall and replace commands
To bind Ctrl-R and Alt-R to replaceall and replace commands, you can add the following lines to your ~/.config/micro/bindings.json file:
"Alt-r": "replace",
"Ctrl-r": "replaceall"
By default Ctrl-R toggles the “ruler” command, which shows the line numbers. As of 2023 default keys don’t have a keybinding for replacing text. Luckily everything can be done using Ctrl-E and writing the command’s there. Commands are saved to ~/.config/micro/settings.json file.
Set a custom colorscheme
I emphatise cleanliness in my setup, everything out of my way. I want the default background for all of my programs, which is assigned by the terminal emulator. AFAIK there is no "terminal" variable as there is in tmux (Ctrl-b :)
set -g status-style bg=terminal
But micro has a variety of themes to use, i chose dukeubuntu-tc, maybe because orange is my favorite colour. You copy a theme file from here:
https://github.com/zyedidia/micro/tree/0859f4aa36d69e5cdb92b868dfc08498fd8a1d70/runtime/colorschemes
to ~/.config/micro/colorschemes and tweak it to your hearts content.
With these customizations micro is a very intuitive editor. I highly recommend checking it out!
Links
Stackoverflow thread: https://stackoverflow.com/questions/69396856/tmux-micro-text-editor-shift-arrow-echo-keycode
Micro's author note: https://github.com/zyedidia/micro/issues/983\#issuecomment-355867571
Update #1 (16. June 2023)
Micro does not have anything binded to alt hjkl keys, so let's turn them into vi-style movement keys
"Alt-h": "CursorLeft",
"Alt-j": "CursorDown",
"Alt-k": "CursorUp",
"Alt-l": "CursorRight"
This is way nicer than moving with arrow keys, especially with those cramped laptop arrow keys! However, there are some emacs keys out of the box. You can use them for moving word to word and line start to line end.
// Emacs-style keybindings
// These are installed by default
// No need to copy these keys
"Alt-f": "WordRight",
"Alt-b": "WordLeft",
"Alt-a": "StartOfLine",
"Alt-e": "EndOfLine"