Shortcuts use
^forCtrlandM-forAlt(Meta).
Runnano --versionto confirm your build supports all features.
| Command | Action |
|---|---|
nano file.py |
Open file (create if absent) |
nano +42 file.py |
Open and jump to line 42 |
nano -l file.py |
Open with line numbers enabled |
nano -i file.py |
Auto-indent mode |
nano -A file.py |
Smart home key (first non-whitespace char) |
nano -E file.py |
Convert tabs to spaces on save |
nano -T 4 file.py |
Set tab width to 4 spaces |
| Shortcut | Action |
|---|---|
^F / ^B |
Forward / backward one character |
^N / ^P |
Next / previous line |
^A / ^E |
Start / end of line |
M-F / M-B |
Forward / backward one word |
^V / ^Y |
Page down / page up |
M-\ / M-/ |
Jump to first / last line of file |
M-G or ^_ |
Go to specific line (and column): line,col |
M-] |
Jump to matching bracket () [] {} |
Analytics tip:
^_ 42,1jumps straight to line 42 — useful when a Python traceback or dbt compile error points to a line number.
| Shortcut | Action |
|---|---|
^W |
Open search prompt |
^W → Enter |
Find next occurrence |
M-W |
Find next (repeat last search) |
M-Q |
Find previous |
M-C |
Toggle case-sensitive search |
M-R |
Toggle regex search mode |
M-B |
Toggle backward search direction |
^\ |
Open search-and-replace prompt |
At replace prompt → A |
Replace all occurrences at once |
^C |
Cancel search / replace |
Regex tip: With
M-Ractive, patterns like\bref\bwork — handy for finding allref()calls in a dbt model without matchingderefetc.
| Shortcut | Action |
|---|---|
^D |
Delete character under cursor |
^H |
Backspace (delete char before cursor) |
M-D |
Delete word forward |
M-Backspace |
Delete word backward |
^K |
Cut (kill) current line |
M-6 |
Copy current line (without cutting) |
^U |
Paste (uncut) |
M-T |
Cut from cursor to end of file |
^J |
Justify (reflow) current paragraph |
M-J |
Justify entire file |
M-U |
Undo |
M-E |
Redo |
^I |
Insert a tab character |
M-} / M-{ |
Indent / unindent selected block |
Python/YAML tip:
M-}andM-{are your block indent controls — select a range first, then shift indentation without retyping.
| Shortcut | Action |
|---|---|
M-A or ^^ |
Set mark (start selection) |
| Navigate | Extend selection with any movement key |
^K |
Cut selected region |
M-6 |
Copy selected region |
^U |
Paste at cursor position |
Works like a manual visual-mode. Set mark, move to end of block, then cut or copy.
| Shortcut | Action |
|---|---|
^R |
Insert another file at cursor / open new buffer |
^R then M-F |
Open file in a new buffer (tab-like) |
M-< / M-> |
Switch to previous / next buffer |
^X |
Close current buffer (prompts to save) |
| Shortcut | Action |
|---|---|
^O |
Save (write out) — keeps file open |
^X |
Exit (prompts to save if modified) |
^O then M-D |
Save as DOS format |
^O then M-M |
Save as Mac format |
^O then M-A |
Append to file instead of overwriting |
^O then M-P |
Prepend to file |
| Shortcut | Action |
|---|---|
^G |
Open nano help |
^C |
Show current cursor position (line, col, %) |
M-N |
Toggle line numbers |
M-P |
Toggle whitespace display |
M-X |
Toggle help bar at bottom |
M-C |
Toggle cursor position display |
^L |
Refresh / redraw screen |
M-Z |
Suspend nano to shell (resume with fg) |
^T |
Run a spell check (if spell installed) |
Place this in ~/.nanorc (user) or /etc/nanorc (system-wide).
# === Display ===
set linenumbers # Always show line numbers
set numbercolor cyan # Line number colour
set titlecolor bold,white
set statuscolor bold,black,yellow
# === Editing behaviour ===
set tabsize 4 # Match Python / dbt / YAML convention
set tabstospaces # Expand tabs to spaces on input
set autoindent # Preserve indentation on new lines
set smarthome # First keypress goes to first non-whitespace char
set softwrap # Wrap long lines visually (no hard wrap)
set mouse # Enable mouse click to reposition cursor
# === UX ===
set historylog # Remember search history across sessions
set positionlog # Remember cursor position per file
set zap # Backspace/Del over selected region deletes it
set afterends # M-F/M-B stop at word ends (more Vim-like)
set atblanks # Soft-wrap breaks at word boundaries
# === Syntax highlighting — include bundled definitions ===
include "/usr/share/nano/*.nanorc" # Base set
# include "/usr/share/nano/extra/*.nanorc" # Uncomment if available
# === Analytics-specific syntax files ===
# YAML (dbt profiles.yml, Airflow DAGs, GitHub Actions)
include "/usr/share/nano/yaml.nanorc"
# SQL (dbt models, ad-hoc queries)
include "/usr/share/nano/sql.nanorc"
# Python (pipelines, transforms, FastAPI)
include "/usr/share/nano/python.nanorc"
# TOML (pyproject.toml, dbt packages)
# Grab from: https://github.com/galenguyer/nano-syntax-highlighting
# include "~/.nano/toml.nanorc"Bootstrapping tip: On Debian/Ubuntu
sudo apt install nanoships*.nanorcfiles in/usr/share/nano/. On macOS via Homebrew:brew install nanoputs them under$(brew --prefix)/share/nano/.
OPEN nano +LINE file SEARCH ^W / M-W (next) / M-Q (prev)
SAVE ^O REPLACE ^\
EXIT ^X REGEX SRCH ^W then M-R
UNDO/REDO M-U / M-E GO TO LINE ^_ or M-G
CUT LINE ^K MARK/SELECT M-A then navigate
COPY LINE M-6 INDENT BLK M-} / M-{
PASTE ^U MATCH BRACE M-]
WORD LEFT/RT M-B / M-F NEXT BUFFER M-> / M-<
Last updated: 2026-04 | nano ≥ 5.x assumed