Show Menu
Cheatography

nano Keyboard Shortcuts by

How to get the most out of your nano

.nanorc

set afterends
Make Ctrl+Right and Ctrl+D­elete stop at word ends instead of beginnings
set autoindent
Automa­tically indent a newly created line to the same number of tabs and/or spaces as the previous line (or as the next line if the previous line is the beginning of a paragr­aph).
set consta­ntshow
Constantly display the cursor position in the status bar.
set cutfro­mcursor
Use cut-fr­om-­cur­sor­-to­-en­d-o­f-line by default, instead of cutting the whole line
set guides­tripe number
Draw a vertical stripe at the given column, to help judge the width of the text.
set stripe­color [bold,­][i­talic,]fgcolo­r,b­gcolor
Use this color combin­ation for the vertical guiding stripe
set keycolor [bold,­][i­talic,]fgcolo­r,b­gcolor
Use this color combin­ation for the shortcut key combos in the two help lines at the bottom of the screen
set linenu­mbers
play line numbers to the left of the text area.
set number­color [bold,­][i­talic,]fgcolo­r,b­gcolor
Use this color combin­ation for line numbers
set mouse
Enable mouse support, if available for your system
set nohelp
Don’t display the two help lines at the bottom of the screen
set saveonexit
Save a changed buffer automa­tically
set scroll­ercolor fgcolo­r,b­gcolor
Use this color combin­ation for the indicator alias "­scr­ollbar
set select­edcolor [bold,­][i­talic,]fgcolo­r,b­gcolor
Use this color combin­ation for selected text.
set speller "program [argument ...]"
Use the given program to do spell checking and correcting
set stateflags
Use the top-right corner of the screen for showing some state flags
set status­color [bold,­][i­talic,]fgcolo­r,b­gcolor
Use this color combin­ation for the status bar
set tabsize number
Use a tab size of number columns
set titlecolor [bold,­][i­talic,]fgcolo­r,b­gcolor
Use this color combin­ation for the title bar

Extra Info

Editing the ~/.nanorc file will enable changes to your nano when you open it.

Statef­lags: I when auto-i­nde­nting, M when the mark is on, L when hard-w­rapping (breaking long lines), R when recording a macro, and S when soft-w­rapping

Valid names for the foreground and background colours are: red, green, blue, magenta, yellow, cyan, white, and black. Each of these eight names may be prefixed with the word light to get a brighter version of that colour. The word grey or gray may be used as a synonym for lightb­lack. On a Linux console, light does not have any effect for a background colour. On terminal emulators that can do at least 256 colours, other valid (but unpref­ixable) colour names are: pink, purple, mauve, lagoon, mint, lime, peach, orange, latte, rosy, beet, plum, sea, sky, slate, teal, sage, brown, ocher, sand, tawny, brick, crimson, and normal -- where normal means the default foreground or background colour. On such emulators, the colour may also be specified as a three-­digit hexade­cimal number prefixed with #, with the digits repres­enting the amounts of red, green, and blue, respec­tively. This tells nano to select from the available palette the colour that approx­imates the given values.

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

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
 

Toggles

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

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
 

Moving Around

Ctrl-F
Go forward one character
Ctrl-B
Go back one character
Ctrl-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
 

Comments

No comments yet. Add yours below!

Add a Comment

Your Comment

Please enter your name.

    Please enter your email address

      Please enter your Comment.

          Related Cheat Sheets

          Linux Command Line Cheat Sheet
          nano text editor Cheat Sheet
          Nano Editor Keyboard Shortcuts