In my opinion, the command-line text editor "micro" is the best alternative for vi/vim and offers more functions than nano. What's so special about it, is the intuitive UI, since many key combinations correspond to those known from other Mac programms (such as control+s for saving or control+f for searching, etc.). However, you have to use the control key instead of the command key, as the command key is already assigned to the terminal programme.
Installation
Use homebrew for installing micro on your Mac:
brew install microSetup for MacOS:
The keybindings on MacOS for micro are a bit problematic. The best you can do is use iTerm2 instead of the build-in Terminal.
In iTerm2 go to Preferences->Profiles->Keys->Presets and choose xterm defaults and select Esc+ for Left Option Key as well.
If you still insist on using the build-in Terminal, be sure to set Use Option key as Meta key under Preferences->Profiles->Keyboard to use option as alt.
Plugins
There are some very usefull plugins for micro. You can show a list of all available plugins by typing plugin available in the micro command line or you can find it here online.
My favorites plugins for micro are:
- filemanager
- editorconfig
You can install a plugin in the micro command line by typing:
plugin install <name of plugin>You can list all installed plugins by typing in the micro command line:
plugin listKeybindings for micro on macOS
The following keybindings asume, that you use iTerm2 with the settings mentioned above (see Setup for MacOS).
| key | function |
|---|---|
| control+q or F10 | quit editor or quit current window |
| control+s or F2 | save current file |
| control+e | open command line |
| control+z | undo |
| control+y | redo |
| control+w | cycle between window splits (see command vsplit and hsplit) |
| control+r | toggle line numbers on or off |
| Moving around: | |
| ← / → / ↓ / ↑ | move cursor arround |
| option+← / → | move cursor to next word |
| fn+→ or esc+e | move cursor to end of line |
| fn+← or esc+a | move cursor to start of line |
| fn+↓ | move cursor page down |
| fn+↑ | move cursor page up |
| control+l | jump to line (prompts for line nr) |
| Search and Replace: | |
| control+f or F7 | search |
| control+n | jump to next hit of current search |
| control+p | jump to previous hit of current search |
| Text-Selection | |
| shift+← / → | select character left/right |
| shift+option+← | select word left/right |
| shift+fn+→ | select until end of line |
| shift+fn+← | select until start of line |