nano Cheatsheet
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.
| Command | Description |
|---|---|
nano | Open empty editor |
nano file | Open/create file |
nano +10 file | Open at line 10 |
nano +10,5 file | Open at line 10, col 5 |
nano -v file | View only (read-only) |
nano -l file | Show line numbers |
Save & Exit
Save files and close the editor.
| Command | Description |
|---|---|
Ctrl+O | Save file (Write Out) |
Ctrl+X | Exit nano |
Ctrl+X then Y | Save and exit |
Ctrl+X then N | Exit without saving |
Ctrl+O then Enter | Save with same name |
Navigation
Move around the file.
| Command | Description |
|---|---|
Arrow keys | Move cursor |
Ctrl+F | Move forward (right) |
Ctrl+B | Move backward (left) |
Ctrl+P | Previous line (up) |
Ctrl+N | Next line (down) |
Ctrl+A | Beginning of line |
Ctrl+E | End of line |
Page Navigation
Move through the file quickly.
| Command | Description |
|---|---|
Ctrl+V | Page down |
Ctrl+Y | Page up |
Ctrl+_ | Go to line number |
Alt+\ | First line |
Alt+/ | Last line |
Alt+G | Go to line (same as Ctrl+_) |
Cut, Copy & Paste
Manipulate text blocks.
| Command | Description |
|---|---|
Ctrl+K | Cut current line |
Alt+6 | Copy current line |
Ctrl+U | Paste (uncut) |
Ctrl+K (multiple) | Cut multiple lines |
Alt+A | Start selection mark |
Ctrl+K | Cut selection |
Selection
Select text blocks.
| Command | Description |
|---|---|
Alt+A | Start selection |
Shift+Arrow | Select text |
Alt+A then move | Extend selection |
Ctrl+^ | Mark text start |
Alt+^ | Copy selection |
Delete
Remove text from the file.
| Command | Description |
|---|---|
Backspace | Delete char before |
Delete | Delete char at cursor |
Ctrl+H | Delete char before |
Ctrl+D | Delete char at cursor |
Ctrl+K | Delete (cut) line |
Alt+Delete | Delete word before |
Ctrl+Delete | Delete word after |
Search
Find text in the file.
| Command | Description |
|---|---|
Ctrl+W | Search (Where Is) |
Alt+W | Repeat last search |
Ctrl+W then Enter | Find next |
Alt+B | Search backward |
Alt+C | Case sensitive toggle |
Alt+R | Regex toggle |
Search & Replace
Find and replace text.
| Command | Description |
|---|---|
Ctrl+\ | Search and replace |
Alt+R | Replace (in search) |
Y | Replace this instance |
N | Skip this instance |
A | Replace all |
Ctrl+C | Cancel replace |
Undo & Redo
Reverse and repeat changes.
| Command | Description |
|---|---|
Alt+U | Undo |
Alt+E | Redo |
Line Operations
Work with lines.
| Command | Description |
|---|---|
Ctrl+K | Cut line |
Alt+6 | Copy line |
Ctrl+U | Paste line |
Ctrl+J | Justify paragraph |
Alt+J | Justify entire file |
Alt+3 | Comment/uncomment |
Display Options
Change how content is displayed.
| Command | Description |
|---|---|
Alt+# | Toggle line numbers |
Alt+P | Toggle whitespace |
Alt+Y | Toggle syntax color |
Alt+X | Toggle help display |
Alt+L | Toggle long line wrap |
Alt+S | Toggle smooth scroll |
Multiple Buffers
Work with multiple files.
| Command | Description |
|---|---|
Ctrl+R | Read file into buffer |
Alt+< | Switch to prev buffer |
Alt+> | Switch to next buffer |
nano file1 file2 | Open multiple files |
Spell Check
Check spelling in text.
| Command | Description |
|---|---|
Ctrl+T | Invoke spell checker |
(requires spell installed) |
Information
Get help and file info.
| Command | Description |
|---|---|
Ctrl+G | Display help |
Ctrl+C | Cursor position info |
Alt+D | Word/line/char count |
Command Line Options
Launch nano with options.
| Command | Description |
|---|---|
nano -l file | Show line numbers |
nano -m file | Enable mouse |
nano -i file | Auto indent |
nano -E file | Convert tabs to spaces |
nano -T 4 file | Set tab size to 4 |
nano -w file | Don’t wrap lines |
nano -c file | Show cursor position |
nano -B file | Backup before edit |
Configuration
Customize nano settings.
| Command | Description |
|---|---|
~/.nanorc | User config file |
/etc/nanorc | System config |
set linenumbers | Show line numbers |
set autoindent | Auto indentation |
set tabsize 4 | Tab width |
set mouse | Enable mouse |
include /usr/share/nano/*.nanorc | Syntax highlighting |