Skip to content

Instantly share code, notes, and snippets.

@pizofreude
Last active April 22, 2026 18:19
Show Gist options
  • Select an option

  • Save pizofreude/d00b99a6b3fde9db7ba36fcbedb487ea to your computer and use it in GitHub Desktop.

Select an option

Save pizofreude/d00b99a6b3fde9db7ba36fcbedb487ea to your computer and use it in GitHub Desktop.
Nano Cheatsheet for Fellow Analytics Engineer: Covers 8 sections: opening, navigation, search/replace, editing, selection, buffers, saving, and a ready-to-paste `.nanorc` config tuned for Python/dbt/YAML/SQL workflows. The quick reference card at the bottom is designed to be readable even after you've internalized most shortcuts. One thing to ac…

Nano Cheatsheet — Fellow Analytics Engineer

Shortcuts use ^ for Ctrl and M- for Alt (Meta).
Run nano --version to confirm your build supports all features.


Opening Files

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

Navigation

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,1 jumps straight to line 42 — useful when a Python traceback or dbt compile error points to a line number.


Search & Replace

Shortcut Action
^W Open search prompt
^WEnter 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-R active, patterns like \bref\b work — handy for finding all ref() calls in a dbt model without matching deref etc.


Editing

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-} and M-{ are your block indent controls — select a range first, then shift indentation without retyping.


Selection (Mark)

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.


Multiple Buffers & Files

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)

Saving & Exiting

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

Miscellaneous

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)

.nanorc Config — Analytics Engineer Setup

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 nano ships *.nanorc files in /usr/share/nano/. On macOS via Homebrew: brew install nano puts them under $(brew --prefix)/share/nano/.


Quick Reference Card

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment