Nano is a simple, user-friendly text editor often found on Unix-like systems such as Linux. It’s favored for quick file editing due to its accessibility directly from the terminal. In this tutorial, you’ll learn the basic functions of nano with a comprehensive table of keybindings. The most commonly used functions are highlighted in bold to help you get started quickly.
Starting Nano
To start nano, simply type nano followed by the filename you wish to edit in the terminal. For example:
nano myfile.txt
If the file doesn’t exist, nano will create it for you.
Table of Nano Keyboard Shortcuts and Functions
| Shortcut | Function |
|---|---|
| Ctrl + G | Display help menu (Get Help) |
| Ctrl + O | Write (save) file (Output) |
| Ctrl + X | Exit nano editor (Exit) |
| Ctrl + W | Search for a string (Where is) |
| Ctrl + K | Cut text (removes the current line or highlighted text) |
| Ctrl + U | Paste text (Uncut text) |
| Ctrl + C | Show cursor position and file information |
| Ctrl + Y | Scroll one page up |
| Ctrl + V | Scroll one page down |
| Ctrl + A | Move cursor to the beginning of the current line |
| Ctrl + E | Move cursor to the end of the current line |
| Ctrl + \\ (backslash) | Search and replace text |
| Ctrl + T | Invoke spell checker |
| Ctrl + _ | Go to a specific line number |
| Ctrl + L | Refresh the screen (Redraw) |
| Ctrl + P | Move the cursor up one line |
| Ctrl + N | Move the cursor down one line |
| Ctrl + F | Move the cursor forward one character |
| Ctrl + B | Move the cursor back one character |
| Alt + A | Start selecting text for cutting or copying (mark text) |
| Alt + 6 | Copy the selected text |
| Ctrl + D | Delete the character under the cursor |
| Alt + U | Undo the last action |
| Alt + E | Redo the last undone action |
| Ctrl + Shift + ^ | Mark text from the cursor position (used for selecting text) |
| Alt + ] | Move the cursor to the next word |
| Alt + [ | Move the cursor to the previous word |
| Alt + < | Move the cursor to the beginning of the file |
| Alt + > | Move the cursor to the end of the file |
| Ctrl + ^ | Set mark for selecting text |
Saving and Exiting in Nano
- Save the file: When you’re ready to save, press Ctrl + O. Nano will prompt you to confirm the filename at the bottom. Press Enter to save the file.
- Exit nano: After saving, press Ctrl + X to exit nano. If you’ve made changes without saving, nano will prompt you to save.
Cutting, Copying, and Pasting Text
- Cutting Text: Press Ctrl + K to cut the entire line. To cut a section of text, first mark it with Alt + A and then press Ctrl + K.
- Copying Text: Mark the text with Alt + A and press Alt + 6 to copy.
- Pasting Text: Press Ctrl + U to paste the cut or copied text.
Searching and Replacing Text
- Search for text: Press Ctrl + W, type the search term, and press Enter.
- Find and replace: Press **Ctrl + \**, enter the search term, then the replacement term, and press Enter.
Undo and Redo
- Undo an action: Press Alt + U.
- Redo an action: Press Alt + E.
Conclusion
Nano is an intuitive and versatile editor, ideal for quick edits and small-scale file management in a terminal. With practice and familiarity with these keyboard shortcuts, you’ll be able to edit files efficiently and effectively.





Leave a Reply