← Back to all cheatsheets
Linux
linuxeditorterminal

Nano Editor Cheat Sheet

Opening Files

  • nano filename - Open/create file
  • nano +line filename - Open file at specific line number
  • nano -w filename - Disable line wrapping

Basic Navigation

  • Arrow keys - Move cursor
  • Ctrl+A - Beginning of line
  • Ctrl+E - End of line
  • Ctrl+Y - Previous page
  • Ctrl+V - Next page
  • **Alt+** - Go to beginning of file
  • Alt+/ - Go to end of file

Search & Replace

  • Ctrl+W - Search (Where is)
  • Alt+W - Search next occurrence
  • **Ctrl+** - Search and replace
  • Alt+R - Replace current match

Editing

  • Ctrl+K - Cut entire line
  • Alt+6 - Copy entire line
  • Ctrl+U - Paste
  • Alt+U - Undo
  • Alt+E - Redo
  • Alt+A - Select text (start/stop marking)
  • Ctrl+6 - Mark text from cursor
  • Alt+} - Indent line/selection
  • Alt+{ - Unindent line/selection

File Operations

  • Ctrl+O - Save (WriteOut)
  • Ctrl+X - Exit
  • Ctrl+R - Insert another file
  • Ctrl+T - Spell check (if available)

Line Operations

  • Ctrl+G - Help
  • Ctrl+C - Show cursor position/line info
  • Alt+G - Go to line number
  • Alt+D - Count words/lines/characters
  • Ctrl+J - Justify paragraph

Useful Toggles

  • Alt+M - Enable/disable mouse support
  • Alt+N - Toggle line numbers
  • Alt+S - Toggle smooth scrolling
  • Alt+I - Auto-indent toggle

Tips

  • Ctrl+G shows help with all commands
  • Use Tab for filename completion when opening files
  • Alt key combinations may vary by terminal - try Esc if Alt doesn’t work
  • Commands are case-sensitive

Essential Commands

The most important commands to remember:

  • Ctrl+O - Save
  • Ctrl+X - Exit
  • Ctrl+W - Search
  • Ctrl+K / Ctrl+U - Cut/Paste