Much as I've embraced the Atom text editor, there are times when the GUI isn't accessible to us, and we are forced to use a Terminal-based text editor.
Now, I'm not one of those crazy types who use emacs or vim - those are the real seasoned pros. (I still don't know how to exit vim, btw.) As such, my terminal editor of choice remains the venerable
nano. Here's some hacks that I recently figured out, to make text editing much easier in
(1) Syntax highlighting
This is such a big one! Syntax highlighting seriously helps a ton. If you're on a Mac, make sure you install
homebrew's version of
nano - you can look at my dotfiles or run the command:
$ brew install nano
Then, edit your
~/.nanorc file to look something like this:
include /usr/local/share/nano/python.nanorc # gives you Python syntax highlighting include /usr/local/share/nano/sh.nanorc # gives you bash shell syntax highlighting
Next time you use
nano (from your user account), syntax highlighting should be enabled!
(2) Keyboard Shortcuts
Here's a laundry list of keyboard shortcuts I've muscle-memorized:
Ctrl-x: quits. There will be a prompt to save the file if it's been modified.
Ctrl-vscrolls down a page
Ctrl-yscrolls up a page
Ctrl-wsearches the document for a term that you type in (think "where")
Ctrl-kcuts the line
Ctrl-upastes a cut line
Ctrl-Shift-6on macOS keyboards) starts a "select" cursor.
Ctrl-ccancels any commands that are 'active'.
Ctrl-oactivates the "save file" dialogue - lets you save your state without quitting.
nano, being not as fancy as
emacs, means it doesn't have the concept of sessions. Doesn't matter - use
tmux to persist!
All-in-all, the biggest one that aids in writing on a terminal editor is syntax highlighting. I wrote this blog post in
nano, and being able to visually see different parts of my text highlighted according to their meaning has made writing much easier.