nano is a simple and user-friendly text editor for Unix-like operating systems. This cheat sheet covers essential nano commands for creating, editing, and navigating text files.
Introduction:
nano is a lightweight text editor that provides a user-friendly interface for editing files in the terminal. It is especially suitable for users who are new to command-line text editors.
Basic Commands:
Command
Description
nano [file]
Open or create a file for editing.
nano -l [file]
Open a file with line numbers displayed.
nano +[line_number] [file]
Open a file and position the cursor at a specific line.
Editing Text:
Command
Description
Ctrl + O
Write changes to the file (Save).
Ctrl + X
Exit nano. If changes are made, it will prompt to save.
Alt + U
Undo the last action.
Alt + E
Redo an undone action.
Navigation:
Command
Description
Arrow keys
Move the cursor in the specified direction.
Ctrl + F
Move forward one page.
Ctrl + B
Move backward one page.
Ctrl + ]
Move to a matching bracket or parenthesis.
Searching and Replacing:
Command
Description
Ctrl + W
Search for text in the file.
Ctrl + \
Replace text in the file.
Alt + W
Repeat the last search.
Cut, Copy, and Paste:
Command
Description
Alt + A
Mark text for cutting or copying.
Ctrl + K
Cut the marked text.
Ctrl + U
Copy the marked text.
Ctrl + Shift + U
Paste the cut or copied text.
Miscellaneous:
Command
Description
Ctrl + G
Display the help menu.
Ctrl + C
Show the current cursor position.
Ctrl + R
Read a file into the editor.
Conclusion
nano is a user-friendly text editor with straightforward commands, making it accessible for users who are new to command-line text editing. This cheat sheet covers essential commands for creating, editing, and navigating text files with nano. Whether you are a beginner or an experienced user, these commands will help you efficiently work with text files in the terminal.