Enjoy Writing with nano
nano is a command line text editor that is
installed on most Linux or BSD distributions. It’s really cute
and offers everything I need to write everything but code. This
note is in fact written with nano, and I also use it to work on
my academic papers. I experience most editors as completely
overloaded with things that I actually don’t need. All of the
following assumes that you are comfortable with hanging around a
shell.
Setup
nano should be installed on your computer if you
use any Unix-like system, and if not, just do a quick research
for your distribution. nano uses a config file for
it’s settings and on my Linux, this file lives under
~/.nanorc. It looks like this:
# Language
include "/usr/share/nano/markdown.nanorc"
# Sets what spelling utility to use.
set speller "aspell -x -c"
# Settings
set atblanks # wrap line at blanks.
set nohelp # Disable the help information
set softwrap # Enable softwrap of lines.
set tabsize 4 # Sets tab-to-spaces size to 4.
set tabstospaces # Converts TAB key press to spaces.
set constantshow # Displays useful info in bottom bar
set casesensitive # Case insensitive search.
set historylog # Save the last 100 history searches for later use.
set zap # Allows you to highlight text and delete it with backspace.
set autoindent # A new line will have the same indent
set minibar # Displays info in bottoms bar.
# Enable and set a working backup directory
set backup # Creates backups of your current file.
set backupdir "~/.cache/nano/backups/" # The location of the backups.
# Enable completion suggestions
bind ^Space complete main Besides nano, I installed aspell and
sdcv. The former is a command line utility that
checks a text file for mistakes, and sdcv is a
command line dictionary. aspell should be easy to
install, again, check your distro for guides. For
sdcv, check the wonderful notes of Rek Bell, on how
to “install a terminal dictionary”.
Usage
nano let’s you write directly, and doesn’t need
you to memorize some cryptic keyboard shortcuts to change
between reading and editing modes. My settings above slightly
change how nano is looking by removing some of the
UI. Most notably, there is a shortcut help on the bottom of the
screen, that I don’t need present all the time. If you
M- or ^ in the snippets bellow, on my
systems that means press Alt key and… and
press Ctrl key and …
- to create/edit plain text file enter
nano "hello kitty.txt"in your terminal - show
nanohelp page^G(and close it with^Cor^X) - toggle shortcut help
M-X - save
^Sand close file^X, and don’t worry, if there are unsaved changes,nanowill ask you - get the current word and character count with
M-D
Spell Checking
^Tfollowed by^Swill kick off the spell checker that is set up in.nanorc
If there is no spell checker set up, this will not work. But
if that is done correctly, aspell will start a
process of going through all the words that it thinks are wrong
and let’s you decide what to do with it. There are most likely
ways on how to use different languages for the spell checking,
but I haven’t looked into that yet.
Dictionary Lookup
^Topens the command prompt, and ifsdcvis set up correctly, simply typesdcv WORDnanowill copy the results of the dictionary lookup directly into the file that you have open right now. You can then read or copy parts of that, and if you want to remove it simply undo the lookup withM-U.
Completion Suggestions
This functionality is included in newer nano
version, but has to be mapped to a keyboard shortcut. In my
settings I mapped it to ^Space, so pressing
Ctrl and Space automatically completes a word.
Keeping Ctrl pressed and repeatedly pressing
Space rotates through all the possibilities, which
are taken from the words in the present file.