The nano editor is a simple, user-friendly, text-based editor commonly used in Linux and Unix systems. Below are the essential commands to navigate and work with nano:
Opening nano
- Open a file with
nano <filename>
(e.g.,nano myfile.txt
). - If the file doesn’t exist, nano creates it.
Navigating Text
- Arrow keys: Move the cursor up, down, left, or right.
- Ctrl+A: Move to the beginning of the current line.
- Ctrl+E: Move to the end of the current line.
- Ctrl+Y: Scroll up one screen.
- Ctrl+V: Scroll down one screen.
- Ctrl+_: Jump to a specific line and column (enter
line,column
).
Editing Text
- Backspace/Delete: Remove characters.
- Ctrl+K: Cut the entire current line (can be pasted later).
- Ctrl+U: Paste previously cut text.
- Alt+6: Copy selected text (use arrow keys to highlight).
- Ctrl+J: Justify the current paragraph.
Searching
- Ctrl+W: Search for a string or text.
- Alt+W: Repeat the last search.
- Ctrl+\: Search and replace.
Saving and Exiting
- Ctrl+O: Save changes (write to file).
- Press Enter to confirm the file name.
- Ctrl+X: Exit nano.
- If unsaved changes exist, nano prompts you to save them.
Undo and Redo
- Alt+U: Undo the last action.
- Alt+E: Redo the last undone action.
File Management
- Ctrl+R: Insert the content of another file into the current file.
- Ctrl+T: Open the file browser to search for a file.
Help and Shortcuts
- Ctrl+G: Display the help menu with all commands.
- Ctrl+C: Show the current cursor position (line and column numbers).
Advanced Features
- Ctrl+T: Spellcheck (if enabled on your system).
- Ctrl+X: Exit nano after saving changes.
Nano displays shortcuts at the bottom of the screen.
- ^ refers to the Ctrl key (e.g., ^X is Ctrl+X).
- M- refers to the Alt key (e.g., M-U is Alt+U).
Mr. Arch Brooks, Software Engineer, Brooks Computing Systems, LLC authored this article.