nano editor tutorial.

nano editor tutorial.#

  1. Opening and Creating Files:

  • To open an existing file or create a new one: [1]

nano filename.txt

(Replace filename.txt with your desired file name.) [1]

  • To open a file with the cursor at a specific line and column:

nano +line_number,column_number filename.txt
  1. Basic Navigation and Editing:

  • Navigation: Use the arrow keys to move the cursor. Page Up/Down keys move a screen at a time.

  • Typing: Begin typing directly after opening the file.

  • Deleting Characters: Use the Backspace key.

  • Deleting a Line: Press Ctrl+K.

  • Cutting Text: Mark text by pressing Alt+A at the start, then move with arrow keys, and press Ctrl+K to cut.

  • Copying Text: Mark text as above, then press Alt+6 to copy.

  • Pasting Text: Navigate to the desired location and press Ctrl+U.

  • Undo/Redo: Alt+U to undo, Alt+R to redo.

  1. Saving and Exiting:

  • Saving Changes (without exiting): Press Ctrl+O. You may be prompted to confirm the filename.

  • Exiting (and saving if prompted): Press Ctrl+X. If changes were made, you’ll be asked to save; press Y for Yes or N for No.

  1. Other Useful Features:

  • Searching: Press Ctrl+W, enter your search term, and press Enter. Press Ctrl+W again and Enter to find the next occurrence.

  • Replacing: Press Ctrl+\ (or Alt+R), enter the search term, then the replacement term. You can choose to replace all or selectively.

  • Help: Press Ctrl+G for a full list of commands and their shortcuts.

Note: The caret symbol ^ indicates the Ctrl key. For example, ^X means Ctrl+X.

1 How to Use Nano, the Linux Command Line Text Editor