Nano Cheat Sheet
A simple terminal text editor. You can type straight away. In the help bar, ^ means Ctrl and M- means Alt (or Esc).
On this page
Basics #
| Shortcut | Action |
|---|---|
| Open or create a file | |
| Edit a system file | |
Ctrl + S | Save |
Ctrl + O, Enter | Save as ("Write Out") |
Ctrl + X | Exit (asks to save if there are changes) |
Ctrl + G | Help |
Ctrl + C | Show the cursor position (line/column) |
Moving #
| Shortcut | Action |
|---|---|
Ctrl + A / Ctrl + E | Start / end of line |
Ctrl + Y / Ctrl + V | Page up / page down |
Alt + \ / Alt + / | Start / end of the file |
Ctrl + _ | Go to a line number |
Ctrl + ←/→ | Word left / right |
Editing #
| Shortcut | Action |
|---|---|
Ctrl + K | Cut the current line (or the selection) |
Alt + 6 | Copy the current line (or the selection) |
Ctrl + U | Paste |
Alt + A | Start selecting (set mark), then move with the arrows |
Alt + U / Alt + E | Undo / redo |
Alt + 3 | Comment / uncomment the line |
Tab / Shift + Tab | Indent / unindent the selection |
Ctrl + J | Justify the paragraph |
Ctrl + R | Insert another file here |
Search & Replace #
| Shortcut | Action |
|---|---|
Ctrl + W | Search |
Alt + W | Find next |
Alt + Q | Find previous |
Ctrl + \ | Search and replace |
Options #
| Shortcut / flag | Action |
|---|---|
Alt + N | Toggle line numbers |
Alt + P | Show whitespace |
| Open with line numbers | |
| Open at line 25 | |
| Enable mouse support |
~/.nanorc #
set linenumbers
set mouse
set autoindent
set tabsize 4
set tabstospaces
set softwrap
include "/usr/share/nano/*.nanorc" # syntax highlighting
Tips #
- Make nano the default editor (for
git commit,crontab -e…):export EDITOR=nanoin~/.bashrc. - Git only:
git config --global core.editor nano.
nanoSimple terminal text editor. nano [options] [+line[,column]] file
| Option | What it does |
|---|---|
+25 | Open at line 25 (+25,8 = line 25, column 8) |
-l, --linenumbers | Show line numbers |
-m, --mouse | Mouse support |
-i, --autoindent | Keep the indentation of the previous line |
-E, --tabstospaces | Type spaces instead of tabs |
-T 4, --tabsize=4 | Tab width |
-w, --nowrap | Don't wrap long lines while typing |
--softwrap | Wrap long lines on screen only |
-B, --backup | Keep a backup file~ when saving |
-v, --view | Read-only |
-c, --constantshow | Always show the cursor position |
-x, --nohelp | Hide the help lines at the bottom |
-Y sh, --syntax=sh | Force a syntax highlighting |
-R, --restricted | Restricted mode (can't open other files) |
Settings you always want go in ~/.nanorc (set linenumbers, set mouse…).
Nothing on this sheet matches “”.