# info > nano

---
type: CommandReference
command: nano
mode: info
section: ""
source: info
---

## Quick Reference

- `nano [FILE]` — open file for editing
- `nano +LINE FILE` — open at line number
- `nano +LINE,COLUMN FILE` — open at line and column
- `nano +/STRING FILE` — open at first occurrence of string
- `nano +?STRING FILE` — open at last occurrence of string
- `nano -` — read from stdin
- `^X` — exit (or close current buffer)
- `^O` — write out (save)
- `^W` — search forward
- `^\` — search and replace
- `^K` — cut line (or selected text)
- `^U` — paste
- `^G` — help
- `^C` — show cursor position

## Name

GNU nano is a small and friendly text editor with undo/redo, syntax coloring, interactive search-and-replace, auto-indentation, line numbers, word completion, file locking, backup files, and internationalization support.

## Synopsis

nano [OPTION]... [[+LINE[,COLUMN]|+[crCR](/|?)STRING] FILE]...
- `+LINE` — start at given line (negative counts from end)
- `+LINE,COLUMN` — start at line and column
- `+c` — case-sensitive search
- `+r` — interpret string as regular expression
- `+/STRING` — start at first occurrence of STRING
- `+?STRING` — start at last occurrence of STRING
- `-` — read data from stdin into a buffer

## Options

### Basic and Help

- `-h, --help` — show summary of options and exit
- `-V, --version` — show version and exit

### Editing Behavior

- `-b, --breaklonglines` — automatically hard-wrap overlong lines (opposite of `-w`)
- `-w, --nowrap` — do not hard-wrap (default)
- `-i, --autoindent` — indent new line to match previous/next line
- `-k, --cutfromcursor` — cut from cursor to end of line instead of whole line
- `-Z, --zap` — let Backspace/Delete erase marked region (without affecting cutbuffer)
- `-E, --tabstospaces` — convert typed tabs to spaces
- `-T NUMBER, --tabsize=NUMBER` — set displayed tab width (default 8)
- `-r NUMBER, --fill=NUMBER` — set target width for justifying and wrapping (default -8)
- `-O, --bookstyle` — treat lines starting with whitespace as paragraph beginnings (when justifying)
- `-Q "REGEX", --quotestr="REGEX"` — quoting regex for rejustifying (default: `^([ \t]*([!#%:;>|}]|//))+`)
- `-W, --wordbounds` — treat punctuation as part of words
- `-X "CHARACTERS", --wordchars="CHARACTERS"` — specify additional word characters
- `-y, --afterends` — Ctrl+Right/Ctrl+Delete stop at word ends instead of beginnings
- `-M, --trimblanks` — snip trailing whitespace when wrapping/justifying
- `-J, --guidestripe` — draw vertical stripe at given column (use `set stripecolor` to color)
- `-a, --atblanks` — soft-wrap at whitespace instead of screen edge
- `-S, --softwrap` — display overlong lines on multiple screen rows
- `-j, --jumpyscrolling` — scroll per half-screen instead of per line
- `-L, --nonewlines` — don't automatically add newline at end of file
- `-U, --quickblank` — status messages disappear after 1 keystroke (or 0.8s with minibar/zero)
- `-c, --constantshow` — constantly show cursor position (line, column, character)
- `-l, --linenumbers` — display line numbers
- `-q, --indicator` — show scrollbar on right side
- `-D, --boldtext` — use bold instead of reverse video
- `-x, --nohelp` — hide help lines (expert mode)
- `-e, --emptyline` — leave line below title bar blank
- `-%, --stateflags` — show state flags (I, M, L, R, S) in top-right corner
- `-_, --minibar` — suppress title bar, show info at bottom
- `-0, --zero` — hide all interface elements (title, status, help)
- `-g, --showcursor` — show cursor in file browser/help viewer (for accessibility)
- `-d, --rebinddelete` — make Delete and Backspace work properly
- `-K, --rawsequences` — interpret escape sequences directly (disables mouse)

### File Handling

- `-B, --backup` — save backup of previous version (filename~)
- `-C DIRECTORY, --backupdir=DIRECTORY` — keep numbered backups in directory
- `-F, --multibuffer` — read file into new buffer by default
- `-G, --locking` — enable vim-style file locking
- `-H, --historylog` — save last 100 search/replace strings and commands
- `-I, --ignorercfiles` — ignore system and user nanorc files
- `-N, --noconvert` — disable automatic conversion from DOS/Mac format
- `-P, --positionlog` — remember cursor position for last 200 files
- `-R, --restricted` — restricted mode (no read/write outside command-line files, no suspend, no spell check)
- `-f FILE, --rcfile=FILE` — read only this rcfile
- `-n, --noread` — treat names as new files (for writing to pipes)
- `-o DIRECTORY, --operatingdir=DIRECTORY` — set operating directory (chroot-like)
- `-p, --preserve` — preserve XON/XOFF (`^Q`/`^S`)
- `-s "PROGRAM", --speller="PROGRAM"` — use specified spell checker
- `-t, --saveonexit` — save changed buffer without prompting on exit
- `-u, --unix` — save in Unix format by default
- `-v, --view` — read-only mode
- `-Y NAME, --syntax=NAME` — specify syntax for highlighting
- `-! --magic` — use libmagic to determine syntax when name/header don't match

## Feature Toggles (Meta-Key Shortcuts)

- `M-C` — toggle constant cursor position display
- `M-H` — toggle smart Home key
- `M-I` — toggle auto-indent
- `M-K` — toggle cut-from-cursor
- `M-L` — toggle long-line wrapping
- `M-M` — toggle mouse support
- `M-N` — toggle line numbers
- `M-O` — toggle tabs to spaces
- `M-P` — toggle whitespace display
- `M-S` — toggle soft wrapping
- `M-X` — toggle expert mode (no help lines)
- `M-Y` — toggle syntax coloring
- `M-Z` — toggle hidden interface (title+status bar, not help lines)

## Key Bindings (Default)

### Main Editor

| Key | Function |
|-----|----------|
| `^A` | beginning of line |
| `^B` | back one character |
| `^C` | report cursor position |
| `^D` | delete character under cursor |
| `^E` | end of line |
| `^F` | forward one character |
| `^G` | help |
| `^H` | backspace |
| `^I` | tab |
| `^J` | justify paragraph |
| `^K` | cut line (or marked region) |
| `^L` | refresh screen |
| `^M` | enter |
| `^N` | next line |
| `^O` | write out |
| `^P` | previous line |
| `^Q` | (if preserved) XON |
| `^R` | insert file |
| `^S` | (if preserved) XOFF |
| `^T` | execute command |
| `^U` | paste |
| `^V` | page down |
| `^W` | search forward |
| `^X` | exit |
| `^Y` | page up |
| `^Z` | (if bound) suspend |
| `^\` | search and replace |
| `^^` | set/unset mark |
| `^_` | go to line |
| `^]` | complete word |
| `M-A` | mark |
| `M-B` | backward search |
| `M-C` | toggle case sensitivity |
| `M-D` | delete word right |
| `M-E` | end of paragraph |
| `M-F` | forward word |
| `M-G` | go to line (alternative) |
| `M-H` | smart home |
| `M-I` | auto-indent toggle |
| `M-J` | full justify |
| `M-K` | cut-from-cursor toggle |
| `M-L` | break-long-lines toggle |
| `M-M` | mouse toggle |
| `M-N` | line numbers toggle |
| `M-O` | tabs-to-spaces toggle |
| `M-P` | whitespace display toggle |
| `M-Q` | (unused) |
| `M-R` | regex toggle |
| `M-S` | softwrap toggle |
| `M-T` | cut to end of file |
| `M-U` | undo |
| `M-V` | verbatim input |
| `M-W` | find next forward |
| `M-X` | nohelp toggle |
| `M-Y` | syntax toggle |
| `M-Z` | zero toggle |
| `M-6` | copy line |
| `M-Ins` | place anchor |
| `M-PgUp` | previous anchor |
| `M-PgDn` | next anchor |
| `M-Up` | scroll up |
| `M-Down` | scroll down |
| `M-Left` | previous word |
| `M-Right` | next word |
| `M-Del` | zap (delete marked region) |
| `Sh-M-<letter>` | (same as M-<letter> unless rebound) |
| `F1-F24` | function keys |
| `Ins` | toggle insert/overwrite |
| `Del` | delete character under cursor |

## Examples

### Basic editing

shell
nano myfile.txt
### Open at specific line and column

shell
nano +10,5 myfile.txt
### Open at first occurrence of a string

shell
nano +/TODO myfile.txt
### Open at last occurrence (case-sensitive, regex)

shell
nano +cR/?error myfile.txt
### Read from stdin

shell
echo "hello world" | nano -
### Use restricted mode

shell
rnano myfile.txt
### Pipe output of command into a buffer

shell
ls -la | nano -
## See Also

- [Pico Compatibility](https://nano-editor.org) — differences between nano and Pico
- [Nanorc Files](https://www.nano-editor.org/dist/latest/nanorc.5.html) — configuration file format
- GNU info manual: `info nano`
- [GNU nano website](https://nano-editor.org)