Nano text editor
Description of the Nano text editor
Nano — a console text editor. It’s used in Unix-like operating systems.
Installing Nano
The nano editor is usually pre-installed on most VPS and dedicated servers, allowing you to start editing files right from the console. In rare cases, it might not be installed, and then you can install it using your Linux distribution’s package manager:
CentOS:
yum install nano
Debian, Ubuntu:
apt-get install nano
Nano Interface and Keyboard Shortcuts
- Top bar — shows the editor version, the file being edited, and whether changes have been made.
- Editing area
- Status bar — displays informational messages
- Bottom of the window shows the key combinations for main editing functions (the “^” symbol means pressing Ctrl, and double means Esc)
Common Keyboard Shortcuts:
- Ctrl+G or F1 — Show help
- Ctrl+X or F2 — Exit nano
- Ctrl+O or F3 — Save changes
- Ctrl+J or F4 — Justify the current paragraph (paragraphs separated by an empty line)
- Ctrl+R or F5 — Insert contents of another file
- Ctrl+W or F6 — Search within the file
- Ctrl+Y or F7 — Page up
- Ctrl+V or F8 — Page down
- Ctrl+K or F9 — Cut the current line and save it to the buffer
- Ctrl+U or F10 — Paste from buffer
- Ctrl+C or F11 — Show cursor position
- Ctrl+T or F12 — Check spelling
Nano Options
Open a file with:
nano filename
Or with additional options:
nano –Option1 Option2 … OptionN +line,column filename
You can find the full list of options in the help:
nano -h
Useful options for getting started:
- -h, -? — Show help
- +row,column — Start at a specific line and column
- -S — Smooth scrolling (line by line)
- -c — Show cursor position
- -i — Auto-indent new lines
- -u — Enable undo (Alt-U — undo, Alt-E — redo)
- -v — View mode
- -w — Disable line wrapping
- -x — Hide help lines at the bottom
- -B — Keep backup copies of files
Editing Actions
Basic editing actions in nano (the Meta m key can be replaced with Esc):
- Alt+A — Start selecting text
- Ctrl+K — Cut selected text
- Alt+6 — Copy selected text
- Ctrl+U — Paste from buffer
- m+\ — Go to the first line of the file
- m+/ — Go to the last line of the file
- Ctrl+_ or m+G — Go to a specific line and column
- m+W — Repeat the last search
- m+6 — Copy the current line to the buffer
- m+{ / m+} — Decrease/Increase indentation
- Home / End — Go to the beginning/end of the current line
- m+0 / m+9 — Go to the beginning/end of the current paragraph
- m+T — Cut from the cursor to the end of the file
- m+J — Justify the entire text
- m+D — Count words, lines, and characters
- m+Y — Enable/disable syntax highlighting