Skip to main content

Nano Editor Reference

Below is a representation of the help-text displayed in the nano editor when the key combination ^G (control+G) is pressed.

I have posted this here because editing a file is obviously a very visual exercise and so warrants an entry in the Reference wiki. Editing a file with Nano is a sufficiently different experience for a VI user either connected over SSH or locally. Also because I have so far failed to learn enough commands to make Nano editing a pleasant experience. I will surely be using this page for reference a lot and expect it will also be useful to others.

There seems to be very little online with regard to command reference for the Nano editor. With such a useful help screen this is not surprising. However this doesn't help the VI user accessing the editor screen with a screen-reader. Reading the help text would involve use of flat-review and slow down editing operations dramatically.

The keystrokes list has been tabulated for ease of navigation. Otherwise it is verbatim from the Nano help window.

Notes for VI use of Nano:

  1. The top line shows three sections. The first is the version of the program. The centre section is the current file being edited or 'new buffer'. The third section is empty until a change is made, at which time the word 'Modified' appears here, triggering most screen-readers to say the word 'modified'.
  2. At the bottom of the screens are three lines which are not part of the editor window. Third from bottom is a line where helpful messages appear and where you will type search strings etc. The bottom two lines show the most common shortcut key combinations and is pretty much inaccessible to a VI user. So remembering the most useful keystroke combinations is vital.
  3. When in 'expert' mode, the bottom two lines of keystroke reminders disappear and the editor window grows by two lines, putting the message line at the bottom of the screen.
  4. I've noticed some pretty bizarre behaviour from Nano used over an SSH connection with Tera-Term. Including some lines being read twice, and sometimes some blank lines appearing at the beginning of the file where there weren't any before. Some of this behaviour may be my host screen-reader, some may not be.
  5. The help suggests using the 'Alt' key for the 'Meta' character. Obviously this is out of the question when accessing the Pi over an SSH connection from a Windows host as in most terminal applications, and most Windows applications of any kind, the 'Alt' key will open the terminal program menu and the keystroke will not be passed to Nano.

The help text verbatim:

Main Nano help Text

The Nano editor is designed to emulate the ease-of-use of the UW Pico text editor. There are four main sections of the editor. The top line shows the version of the program, the current filename being edited, and whether or not the file has been modified. Next is the main editor window showing the file being editied. The status line is the third line from the bottom and shows important messages. The bottom two lines show the most commonly used shortcuts.

The notation for shortcuts is as follows: Control-key sequences are notated with a caret (^) symbol and can be entered either by entering the control (Ctrl) key or by pressing the escape (Esc) key twice. Escape-key sequences are notated with the Meta (M-) symbol and can be entered by pressing either the Esc, Alt or Meta key, depending on the setup of your keyboard. Also, pressing the Esc key twice followed by a three-digit decimal number from 000 to 255 will enter the character with the corresponding value.

The following keystrokes are available in the main editor window. Alternative keys are shown in parentheses:

Key Combo Function
^G (F1) Display the help text
^Y Go up one screen in help text
^V Go down one line in help text
^X (F2) Exit the help text
^O (F3) Save the current buffer
^J (F4) Justify the current paragraph
^R (F5) Insert another file into current file
^W (F6) Search for a string
^Y (F7) Go to previous screen of buffer
^V (F8) Go to next screen of current buffer
^K Cut the current line to the cut buffer (try saying that quickly)
^U Paste from the cut buffer into the current buffer (at cursor position)
^C (F11) Display the position of the current cursor
^T Invoke the spell-checker (if available)
M-\ Go to first line of current buffer
M-/ Go to last line of current buffer
^_ (M-G) Go to line number
^\ (M-R) Replace string or regular expression
^^ (M-A) Mark at current position
M-W Repeat last search
M-^ (M-6) Copy current line to cut buffer without removing it
M-} Indent current line
M-{ Outdent current line
^F Forward one character
^B Backward one character
^<spacebar> Forward one word
M-<spacebar> Backward one word
^P Previous line
^N Next line
^A Beginning of current line
^E End of current line
M-( (M-9) Go to beginning of current paragraph; then back to beginning of subsequent paragraphs for each repeated operation
M-) (M-0) Go to position before next paragraph; and then forward by paragraph for each repeated operation
M-] Go to matching bracket
^M Insert a newline at the current cursor position
^D Delete the character under the cursor (to the right of vertical bar cursor)
^H Delete the character to the left of the cursor
M-T Cut buffer from current cursor position to end
M-J Justify entire buffer
M-D Count the number of words, lines and characters in the buffer
^L Redraw the current screen
^Z Suspend the editor, if suspending is enabled
M-X Help mode enable/disable
M-C Constant cursor mode enable/disable
M-O Use of one more line for editing enable/disable
M-F Move scrolling enable/disable
M-P Whitespace display enable/disable
M-Y Colour syntax highlighting enable/disable
M-H Smart home key enable/disable
M-I Auto-indent enable/disable
M-K Cut to end enable/disable
M-- Scroll back one line without moving the cursor
M-+ Scroll forward one line without moving the cursor
M-< Switch to the previous buffer
M-> Switch to the next buffer
M-V Insert the next keystroke verbatim
^I Insert a tab at the current cursor position
M-L Long line wrap enable/disable
M-Q Conversion of typed tabs to spaces enable/disable
M-B Backup files enable/disable
M-F Multiple file buffers enable/disable
M-M Mouse support enable/disable
M-N No conversion from DOS/Mac format enable/disable
M-Z Editor suspension enable/disable
M-$ Soft-line wrapping enable/disable