Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

nano

nanoΒΆ


πŸš€ Opening & Exiting
CommandDescription
nano fileOpen or create file
nano +N fileOpen file at line N
nano -l fileShow line numbers
nano -v fileOpen in view-only (read-only) mode
nano -B fileCreate backup before saving
nano -m fileEnable mouse support
^XExit nano
^X then YSave and exit
^X then NExit without saving
πŸ’Ύ Saving & Files
ShortcutDescription
^SSave current file
^OSave as (Write Out) β€” prompts for filename
^O then EnterConfirm save with same filename
^RRead (insert) another file at cursor
^T (in filename prompt)Open file browser to pick a file
🧭 Navigation
ShortcutDescription
Arrow keysMove cursor
^F / ^BForward / backward one character
^N / ^PNext / previous line
^ABeginning of line
^EEnd of line
^SpaceForward one word
M-SpaceBackward one word
^VPage down
^YPage up
M-\ or ^HomeGo to first line
M-/ or ^EndGo to last line
^_Go to specific line (and column)
M-GSame as ^_ β€” go to line number
✏️ Editing
ShortcutDescription
^DDelete character under cursor
BackspaceDelete character before cursor
M-BackspaceDelete word to the left
^KCut (kill) current line
M-6Copy current line
^UPaste (uncut)
M-UUndo
M-ERedo
^JJustify (reflow) current paragraph
M-JJustify entire file
TabInsert tab / indent
M-}Indent selected lines
M-{Unindent selected lines
πŸ” Search & Replace
ShortcutDescription
^WSearch (Where is)
^W then ^RSearch and replace
M-WRepeat last search (find next)
M-QRepeat search in reverse

In the search prompt:

KeyDescription
^CCancel search
M-CToggle case sensitivity
M-RToggle regular expressions
M-BToggle backwards search
Up/DownNavigate search history

In the replace prompt:

KeyDescription
YReplace this occurrence
NSkip this occurrence
AReplace all occurrences
πŸ“‹ Selection & Cut/Copy/Paste
ShortcutDescription
M-ASet mark (start selection)
Arrow keysExtend selection after mark
^KCut selected text (or current line)
M-6Copy selected text (or current line)
^UPaste cut/copied text
M-A againCancel mark/selection

Cut buffer tip: ^K multiple times appends to the cut buffer β€” paste all at once with ^U.

πŸͺŸ Multiple Buffers & Toggles
ShortcutDescription
M-<Switch to previous buffer
M->Switch to next buffer
^XClose current buffer
M-IToggle auto-indent
M-NToggle line numbers
M-PToggle whitespace display
M-SToggle soft-wrapping
M-XToggle help bar at bottom
M-CToggle cursor position display
βš™οΈ Configuration (~/.nanorc)
# Line numbers
set linenumbers

# Smooth scrolling
set smooth

# Auto-indent
set autoindent

# Tab size and use spaces
set tabsize 4
set tabstospaces

# Enable mouse
set mouse

# Soft wrap long lines
set softwrap

# Show cursor position
set constantshow

# Backup files
set backup

# Syntax highlighting (load all defaults)
include "/usr/share/nano/*.nanorc"
πŸ’‘ Tips & Tricks
  • Bottom bar shortcuts: nano always shows available shortcuts at the bottom β€” ^ = Ctrl, M- = Alt

  • Line number jump: ^_ then type line,column (e.g. 42,10) to jump precisely

  • Open multiple files: nano file1 file2 β€” use M-< / M-> to switch between them

  • Pipe into nano: echo "hello" | nano - β€” edit piped input

  • View compressed files: zcat file.gz | nano -

  • Syntax highlighting: install language .nanorc files from /usr/share/nano/ or nano-syntax-highlighting package

  • Disable help bar for more editing space: M-X toggles it, or add set nohelp to ~/.nanorc

  • Undo history is session-only β€” changes cannot be undone after reopening a file