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:

CommandDescription
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:

CommandDescription
Ctrl + OWrite changes to the file (Save).
Ctrl + XExit nano. If changes are made, it will prompt to save.
Alt + UUndo the last action.
Alt + ERedo an undone action.

Navigation:

CommandDescription
Arrow keysMove the cursor in the specified direction.
Ctrl + FMove forward one page.
Ctrl + BMove backward one page.
Ctrl + ]Move to a matching bracket or parenthesis.

Searching and Replacing:

CommandDescription
Ctrl + WSearch for text in the file.
Ctrl + \Replace text in the file.
Alt + WRepeat the last search.

Cut, Copy, and Paste:

CommandDescription
Alt + AMark text for cutting or copying.
Ctrl + KCut the marked text.
Ctrl + UCopy the marked text.
Ctrl + Shift + UPaste the cut or copied text.

Miscellaneous:

CommandDescription
Ctrl + GDisplay the help menu.
Ctrl + CShow the current cursor position.
Ctrl + RRead 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.