Jan 25

nano editor keyboard shortcuts

Category: Linux   — Published by tengo on January 25, 2009 at 12:31 pm

nano text editor screenshotThe handy nano editor (official homepage, wikipedia) on linux/unix type systems is a very easy to use little text editor (far more intuitive than the much followed vi) and allows very efficient text editing once you get the knack of the keyboard shortcuts. Read the manual if you are completely new to it.

Most functions to help editing text, reading,saving etc, are accessed via keyboard shortcuts. Special functions use the Control (Ctrl) key, displayed in the help and shortcut lists as ^; the Meta key, displayed as M; or the Escape (Esc) key. The more common functions are displayed permanently on-screen, some aren't. So here a little help:

  • PgUp Ctrl-y
  • PgDn Ctrl-v
  • show cur cursor loc, or cancel search Ctrl-c
  • toggle show cursor location Alt-c
  • exit Ctrl-x
  • save/"write out" Ctrl-o
  • Insert another file at cursor Ctrl-r
  • Search and replace Alt-r
  • toggle syntax highlighting Alt-y
  • help Ctrl-g

How to search and replace with nano

Nano is able to search and replace a pattern in texts. To access this function use "Ctrl" and "". Anyway, on some systems, with foreign language keyboards or non-unix machines (like on Windows) these shortcuts aren't accessible. See bug #127374. On Windows "Alt" (the left one) plus "r" does the trick.

If your are thinking "where is the Meta key on my Windows keyboard?" running Linux, then read this from the nano man page:

"Meta key sequences are entered by holding down the Meta key
(normally the Alt key) and pressing the desired key, or by
pressing the Esc key once and pressing the desired key.  Certain
operating systems "swallow" the Alt key so that it never reaches
the application; if your operating system does this, you should
use the Esc key to generate Meta key sequences."

Read on: the nano FAQ , online Manual, full docs and some tips.

Update March 2nd, 2009:

Today, I found this VERY insightful blog post on nano's advanced features.