Skip to main content

nano Cheatsheet

By Dejan Panovski Updated on Download PDF

Quick reference for Nano text editor shortcuts

Nano is a simple, user-friendly command-line text editor that comes pre-installed on most Linux distributions. Unlike Vim, Nano displays keyboard shortcuts at the bottom of the screen, making it ideal for beginners. The caret symbol (^) represents the Ctrl key.

Open & Create

Open files and create new ones.

CommandDescription
nanoOpen empty editor
nano fileOpen/create file
nano +10 fileOpen at line 10
nano +10,5 fileOpen at line 10, col 5
nano -v fileView only (read-only)
nano -l fileShow line numbers

Save & Exit

Save files and close the editor.

CommandDescription
Ctrl+OSave file (Write Out)
Ctrl+XExit nano
Ctrl+X then YSave and exit
Ctrl+X then NExit without saving
Ctrl+O then EnterSave with same name

Move around the file.

CommandDescription
Arrow keysMove cursor
Ctrl+FMove forward (right)
Ctrl+BMove backward (left)
Ctrl+PPrevious line (up)
Ctrl+NNext line (down)
Ctrl+ABeginning of line
Ctrl+EEnd of line

Move through the file quickly.

CommandDescription
Ctrl+VPage down
Ctrl+YPage up
Ctrl+_Go to line number
Alt+\First line
Alt+/Last line
Alt+GGo to line (same as Ctrl+_)

Cut, Copy & Paste

Manipulate text blocks.

CommandDescription
Ctrl+KCut current line
Alt+6Copy current line
Ctrl+UPaste (uncut)
Ctrl+K (multiple)Cut multiple lines
Alt+AStart selection mark
Ctrl+KCut selection

Selection

Select text blocks.

CommandDescription
Alt+AStart selection
Shift+ArrowSelect text
Alt+A then moveExtend selection
Ctrl+^Mark text start
Alt+^Copy selection

Delete

Remove text from the file.

CommandDescription
BackspaceDelete char before
DeleteDelete char at cursor
Ctrl+HDelete char before
Ctrl+DDelete char at cursor
Ctrl+KDelete (cut) line
Alt+DeleteDelete word before
Ctrl+DeleteDelete word after

Find text in the file.

CommandDescription
Ctrl+WSearch (Where Is)
Alt+WRepeat last search
Ctrl+W then EnterFind next
Alt+BSearch backward
Alt+CCase sensitive toggle
Alt+RRegex toggle

Search & Replace

Find and replace text.

CommandDescription
Ctrl+\Search and replace
Alt+RReplace (in search)
YReplace this instance
NSkip this instance
AReplace all
Ctrl+CCancel replace

Undo & Redo

Reverse and repeat changes.

CommandDescription
Alt+UUndo
Alt+ERedo

Line Operations

Work with lines.

CommandDescription
Ctrl+KCut line
Alt+6Copy line
Ctrl+UPaste line
Ctrl+JJustify paragraph
Alt+JJustify entire file
Alt+3Comment/uncomment

Display Options

Change how content is displayed.

CommandDescription
Alt+#Toggle line numbers
Alt+PToggle whitespace
Alt+YToggle syntax color
Alt+XToggle help display
Alt+LToggle long line wrap
Alt+SToggle smooth scroll

Multiple Buffers

Work with multiple files.

CommandDescription
Ctrl+RRead file into buffer
Alt+<Switch to prev buffer
Alt+>Switch to next buffer
nano file1 file2Open multiple files

Spell Check

Check spelling in text.

CommandDescription
Ctrl+TInvoke spell checker
(requires spell installed)

Information

Get help and file info.

CommandDescription
Ctrl+GDisplay help
Ctrl+CCursor position info
Alt+DWord/line/char count

Command Line Options

Launch nano with options.

CommandDescription
nano -l fileShow line numbers
nano -m fileEnable mouse
nano -i fileAuto indent
nano -E fileConvert tabs to spaces
nano -T 4 fileSet tab size to 4
nano -w fileDon’t wrap lines
nano -c fileShow cursor position
nano -B fileBackup before edit

Configuration

Customize nano settings.

CommandDescription
~/.nanorcUser config file
/etc/nanorcSystem config
set linenumbersShow line numbers
set autoindentAuto indentation
set tabsize 4Tab width
set mouseEnable mouse
include /usr/share/nano/*.nanorcSyntax highlighting