The nano Text Editor

The nano text editor is designed to emulate the functionality and ease-of-use of the Pico text editor. The Control and Meta keys are set by the Linux system. The nano editor is started in Terminal by typing sudo nano [filename] — without the brackets, of course!

The four main sections of the editor

  1. The top line shows the program version, the current filename being edited, and whether or not the file has been modified
  2. Next is the main editor window showing the file being edited
  3. The status line shows important messages
  4. The bottom two lines show the most common editor shortcuts

The notation for shortcuts

Control-key sequences are listed as (Ctrl-). They can be entered either by using the Control (Ctrl) plus another key, or by pressing the Escape (Esc) key twice.

Escape-key sequences are listed as (Esc-). They can be entered using the Esc, Alt, or Meta key, depending on your keyboard setup, followed by the listed key(s). Pressing Esc twice and then typing a three-digit decimal number from 000 to 255 will enter the character with the corresponding decimal value.

Commands available in the main editor window

(Alternative keys are shown in parentheses)

Most Used

Ctrl-G (F1) Display the help text
Ctrl-O (F3) Write the current file to disk
Ctrl-X (F2) Close the current file buffer / Exit from nano
Ctrl-R (F5) Insert another file into the current one
Ctrl-L Refresh (redraw) the current screen
Ctrl-Y (F7) Go to previous screen
Ctrl-V (F8) Go to next screen

Copy and Paste

Ctrl-K (F9) Cut the current line and store it in the cut buffer
Ctrl-U (F10) Uncut from the cut buffer into the current line
Esc-Ctrl- (Esc-6) Copy the current line and store it in the cut buffer
Esc-\\< (Esc-,) Switch to the previous file buffer
Esc-> (Esc-.) Switch to the next file buffer

Editing Text

Ctrl-I Insert a tab at the cursor position
Ctrl-M Insert a newline at the cursor position
Esc-V Insert the next keystroke verbatim
Ctrl-D Delete the character under the cursor
Ctrl-H Delete the character to the left of the cursor
Esc-T Cut from the cursor position to the end of the file
Esc-D Count the number of words, lines, and characters
Ctrl-Z Suspend the editor (if suspend is enabled)

Search and replace

Ctrl-W (F6) Search for a string or a regular expression
Ctrl-\ (F14) (Esc-R) Replace a string or a regular expression
Esc-W (F16) Repeat last search

Moving Around

Ctrl-F Go forward one character
Ctrl-B Go back one character
Ctrl-Space Go forward one word
Esc-Space Go back one word
Ctrl-P Go to previous line
Ctrl-N Go to next line
Ctrl-A Go to beginning of current line
Ctrl-E Go to end of current line
Ctrl-C (F11) Display the position of the cursor
Esc-( (Esc-9) Go to beginning of paragraph; then of previous paragraph
Esc-) (Esc-0) Go just beyond end of paragraph; then of next paragraph
Esc-] Go to the matching bracket
Esc-\ (Esc-|) Go to the first line of the file
Esc-/ (Esc-?) Go to the last line of the file
Ctrl-_ (F13) (Esc-G) Go to line and column number
Esc– (Esc-_) Scroll up one line without scrolling the cursor
Esc-+ (Esc-=) Scroll down one line without scrolling the cursor
Ctrl-Ctrl- (F15) (Esc-A) Mark text at the cursor position

Formatting

Esc-} Indent the current line
Esc-{ Un-indent the current line
Ctrl-J (F4) Justify the current paragraph
Esc-J Justify the entire file

Spelling

Ctrl-T (F12) Invoke the spell checker, if available

Toggles

(Esc-X) Help mode enable/disable
(Esc-C) Constant cursor position display enable/disable
(Esc-O) Use of one more line for editing enable/disable
(Esc-S) Smooth scrolling enable/disable
(Esc-P) Whitespace display enable/disable
(Esc-Y) Color syntax highlighting enable/disable
(Esc-H) Smart home key enable/disable
(Esc-I) Auto indent enable/disable
(Esc-K) Cut to end enable/disable
(Esc-L) Long line wrapping enable/disable
(Esc-Q) Conversion of typed tabs to spaces enable/disable
(Esc-B) Backup files enable/disable
(Esc-F) Multiple file buffers enable/disable
(Esc-M) Mouse support enable/disable
(Esc-N) No conversion from DOS/Mac format enable/disable
(Esc-Z) Suspension enable/disable
(Esc-$) Soft line wrapping enable/disable


See also: