GNU Nano Logo

The Backstory

For many years, my default text editor has been xed as it comes with Linux Mint, my distro of choice for some years. I’ve used xed for most of the bottle.py programs I’ve written. I never really thought about it, just used it as it got the job done. I generally use Nano for editing files over SSH and have also used that for many years.

A few weeks ago, I was thinking about my workflow and wondered why I wasn’t using a terminal based editor? Here’s how I use bottle.py

1. Fire up tmux
2. Run “python3 name-of-program.py“
3. Open another tmux window for Mercurial checkins

Here’s a screenshot of my terminal whilst writing this post:

It started bothering me that I was faffing about having to use my mouse to navigate between the terminal and my text editor. So I decided to find a terminal (non GUI) editor that would suit me.

My Editor Requirements

I was well aware of the hundreds of editors available for Linux, having had a play with most of them at one time or another:

Emacs, Vim, Jed, Vile, Jove, Joe, Nano, mg, etc….

So I had a think about what was vital and what would be nice-to-have features.

Vital

  • Multiple buffers — I usually have at least two source code files open at a time when I’m coding.
  • Good support for keyboard shortcuts — Of course, this is subjective. Emacs and Vim let you do anything, but I don’t normally need that much power! However, most things that I may need to do on a daily basis should have a shortcut.
  • Remapping of keys — I’ve used Colemak since about 2008, so what might be great for QWERTY, may not be great for me.
  • Quickly delete lines — One of the features I really liked with Vim is dd to delete a line, followed by . to delete subsequent lines.

Nice to Have’s

  • Sensible Defaults — This is one of the things I’ve always liked about Nano. You can just start using it. Shortcuts are visible at the bottom of the window if you need them.
  • Show a line at 80 columns — I don’t like long lines of code.
  • Quickly comment / uncomment code — I got very used to xed’s Ctrl-/ for this purpose!
  • Auto ident — I use Python more than any other language, so auto indenting is hard to live without.
  • Syntax Highlighting — Not 100% critical, but is often useful for seeing what’s what.
  • Bookmarks — Very useful to be able to mark lines in files and jump between them.
  • Scroll without moving cursor — I liked this feature I first saw in Vim. You move the screen but the cursor stays where it is
  • Insert a newline above / below current line — Some editors have a shortcut that will insert a newline without having to go to the end of the line, press enter

Where I Looked Closer at Nano

I won’t lie, Nano came first to mind. I was already familiar with it and it seems to be installed everywhere I need it. But did it do what I needed (and would like it to do)?

Yes, it would (I found out after an hour or so)!

I discovered pretty quickly that version 8, released in 2024 had introduced “modern bindings”:

Command-line option -- modernbindings (-/) makes ^Q quit, ^X cut, ^C copy, ^V paste, ^Z undo, ^Y redo, ^O open a file, ^W write a file, ^R replace, ^G find again, ^D find again backwards, ^A set the mark, ^T jump to a line, ^P show the position, and ^E execute.

I look at that as a sensible default. The original shortcuts aren’t terrible, but I like the CUA ones more. So I downloaded the latest tarball (8.6) and compiled it. I added alias nano="nano -/" to my .bashrc (and on all my servers).

What I Needed / Wanted

✓ multiple buffers: set multibuffer
✓ comment / uncomment code: Alt-3
✓ show end of line: set guidestripe 80
✓ syntax highlighting: include /usr/local/share/nano/*.nanorc
✓ quickly delete lines:
Alt-delete to delete entire line
Alt-backspace to delete words
✓ bookmarks: “anchors” in Nano speak.
Alt-Insert to set/unset.
Alt-PgUp / Alt-PgDn to cycle through them
✓ move viewport up and down: Alt-- / Alt-+
✓ insert a newline above / below current line
bind ^N "{home}{enter}{up}" main
bind ^k "{end}{enter}" main

My Tweaks

Many, many years ago,1 I came across the idea of having the arrow keys accessible on the home row using either the CTRL or ALT keys. Similar to this keyboard:

As I was hoping to somewhat optimize my text editing, I figured I’d try and get some often used keys where I wanted them.2 Using QWERTY notation, I now have:

Alt-j — Left
Alt-k — Down
Alt-i — Up
Alt-l — Right
Alt-u — Home
Alt-o — End
Alt-h — Delete
Ctrl-k — Page Down
Ctrl-i — Page Up

Very nice! I’m already used to them after only a few days. If you’re interested, below is my .nanorc

My .nanorc

# $Id: .nanorc,v 1.6 2025/09/15 13:29:21 simon Exp simon $

set multibuffer
set tabsize 4
set tabstospaces
set autoindent
set wordbounds
set quickblank
set trimblanks
set linenumbers
set smarthome
set mouse
set indicator
set guidestripe 80
set positionlog
set quickblank
set stateflags

set brackets ""')>]}"
set matchbrackets "(<[{)>]}"

set keycolor cyan
set functioncolor cyan
set numbercolor yellow

bind M-5 cycle main

#=============================================
# Experimental: bring useful keys to home row
#=============================================

bind M-n left main
bind M-i right main
bind M-u up main
bind M-e down main
bind M-l home main
bind M-y end main
bind M-h delete main

bind ^u pageup main
bind ^e pagedown main

# newline above current line
bind ^n "{home}{enter}{up}" main

# newline below current line
bind ^k "{end}{enter}" main

include /usr/local/share/nano/*.nanorc
include "~/.nano/tpl.nanorc"

Why Not Just Use…

Of course, anyone who comes here may have their own, possibly strong, opinions about which text editor is the one true editor. Fair enough, but I can’t be bothered to spend weeks learning how to use a text editor.

I set out to find a TUI editor to do my work with and have found it with GNU Nano.

I’ll quickly mention why some other, obvious editors didn’t beat Nano for me.

1. Emacs

Sorry, but having to type Ctrl-X Ctrl-C to exit isn’t for me.

2. Vim

Philosophically, I like the idea of a modal editor. However, in practice, I’ve always found Vim’s learning curve not worth the time. If I wrote software for a living, instead of as a hobby, I might invest more time in learning it. Maybe…

3. Micro

Micro does seem interesting. However, Nano with --modern-bindings possibly makes it less interesting.

Conclusion

Like a lot of people, I’ve been unaware of exactly what Nano is capable of. I’ve been pressing pageup repeatedly to get to the top of the screen when I could have just pressed Ctrl-home or Ctrl-end to go to the beginning or end of the file.

Likewise, I never knew that Alt-home and Alt-end would take me to the first / last lines in the viewport.

Embarrassingly, I didn’t know that Nano supported multiple buffers. So like a fool, I’d edit one file on a server, close it, open another one, close that, open the first one again…

Today I’ve just found that Nano supports soft wrapping using Alt-s which has proven useful writing this post in Textile where unwanted newlines are inserted.

I think some people in the Linux world see Nano as our Windows Notepad. Not something to be used by serious people with serious things to do. I never thought that, but after reading the excellent documentation on the Nano website (and man / info pages) I’m now aware of exactly what it can do.

I hope that you too, will have another look at this awesome little editor.

Footnotes

1 I believe it was Ergoemacs that introduced me to this idea.

2 If you want to do this yourself, here are a couple of tips. You press control by moving your palm outwards and not by stretching your pinky! Alt is pressed by moving your thumb outwards. It takes a bit of getting used to but is worth it, I think.