NANO(1)

๐Ÿ“ฆ
version 8.4 ยท 3 versions
, in ubuntu questing

๐ŸŽ€ NANO(1) ๐ŸŽ€

General Commands Manual, bestie, the official nano ๐ŸŒธ chronicles

โœจ NAME โœจ

nano - Nano's ANOther text editor, inspired by Pico ๐Ÿ’…

๐Ÿ’ซ SYNOPSIS ๐Ÿ’ซ

nano [options] [[+line[,column]] file]...

nano [options] [[+[crCR]{/|?}string] file]...

๐Ÿšจ NOTICE ๐Ÿšจ

Okay so, since version 8.0 nano got newcomer friendly ๐Ÿฅบ. Now ^F starts a forward search, ^B starts a backward search, M-F searches the next occurrence forward, and M-B searches the next occurrence backward. If you miss the old behavior and want those keystrokes to do what they did before 8.0, add these lines at the very end of your nanorc file:

    bind ^F forward main
    bind ^B back main
    bind M-F formatter main
    bind M-B linter main

๐Ÿ’– DESCRIPTION ๐Ÿ’–

nano is a small and friendly text editor, and it's giving Pico vibes ๐Ÿฆ‹. It copies the look and feel of Pico, but it's free software, and it has a bunch of features Pico just doesn't, like opening multiple files, scrolling per line, undo/redo, syntax coloring, line numbering, and soft-wrapping overlong lines. Iconic. ๐Ÿ‘‘

When you give a filename on the command line, you can park the cursor on a specific line by putting the line number after a plus sign (+) right before the filename. Add a comma and a number and you can even land it in a specific column. Negative numbers count from the end of the file or line, so you can go backwards too ๐Ÿงš.

You can also park the cursor on the first or last occurrence of a string by writing that string after +/ or +? before the filename. Add c and/or r after the + sign to make the search case sensitive and/or treat the string as a regular expression. Want to turn those off explicitly? Use the uppercase versions instead: C and/or R ๐Ÿ™ˆ. If your string has spaces in it, it needs to be wrapped in quotes. For example, to open a file at the first occurrence of the word "Foo", you'd do:

    nano +c/Foo file

Also, a special case: if you give a dash (-) instead of a filename, nano will read data from standard input ๐Ÿ“.

โŒจ๏ธ EDITING โŒจ๏ธ

Typing letters and using your normal cursor movement keys is all you need to get around a file, super straightforward ๐Ÿ’…. Commands are entered with the Control (^) key and the Alt or Meta (M-) key. Typing ^K deletes the current line and stashes it in the cutbuffer. Hit ^K again in a row and every deleted line gets piled together in the cutbuffer. Any cursor movement or running any other command means the next ^K overwrites the cutbuffer, so be careful bestie ๐Ÿ˜ญ. A ^U pastes whatever is currently in the cutbuffer at your cursor.

When you need a more precise chunk of text, mark its start with ^6, then move the cursor to its end (the marked text gets highlighted โœจ). Use ^K to cut it, or M-6 to copy it to the cutbuffer. You can also save the marked text to a file with ^O, or spell check it with ^T^T.

On some terminals you can select text by holding Shift while using the arrow keys. Holding Ctrl or Alt too makes the stride bigger. Any cursor movement without Shift being held cancels that selection ๐Ÿซถ.

Any valid Unicode code point can be inserted into the buffer by typing M-V followed by the hexadecimal digits of the code point. End it with <Space> or <Enter> if there are fewer than six digits. You can also insert a literal control code (except ^J) by typing M-V followed by the keystroke you want, and yes, it's that deep ๐Ÿคฏ.

The two lines at the bottom of the screen show some important commands, and the built-in help (^G) lists all the available ones ๐Ÿ’œ. The default key bindings can be changed through a nanorc file, so check out nanorc(5) when you're ready to get extra ๐ŸŒˆ.

๐ŸŽ€ OPTIONS ๐ŸŽ€

  • -A, --smarthome โ€” Makes the Home key smarter ๐Ÿง . If you press Home anywhere except the very beginning of the non-whitespace characters on a line, the cursor jumps to that beginning (forwards or backwards). If you're already sitting there, it jumps to the true beginning of the line.
  • -B, --backup โ€” When you save a file, the previous version gets backed up. The backup uses the current filename with a tilde (~) tacked on the end ๐Ÿ“.
  • -C directory, --backupdir=directory โ€” Makes and keeps a uniquely numbered backup every single time a file is saved, instead of just one. This only works when backups are turned on with -B. The numbered files get stored in the directory you specify ๐Ÿ—‚๏ธ.
  • -D, --boldtext โ€” Uses bold instead of reverse video for the interface โœจ. You can override this for specific elements by setting the options titlecolor, statuscolor, promptcolor, minicolor, keycolor, numbercolor, and/or selectedcolor in your nanorc file. See nanorc(5).
  • -E, --tabstospaces โ€” Converts each tab you type into spaces, using however many spaces a tab would take up at that position ๐Ÿ“. (Heads up: pasted tabs are not converted.)
  • -F, --multibuffer โ€” Reads a file into a new buffer by default ๐Ÿ“š.
  • -G, --locking โ€” Uses vim-style file locking when you edit files ๐Ÿ”’.
  • -H, --historylog โ€” Saves the last hundred search strings, replacement strings, and executed commands so you can reuse them in later sessions. Main character memory ๐Ÿง ๐Ÿ’….
  • -I, --ignorercfiles โ€” Don't look at the system's nanorc or the user's nanorc ๐Ÿ™….
  • -J number, --guidestripe=number โ€” Draws a vertical stripe at the given column, so you can judge how wide your text is ๐Ÿ“. (You can change the stripe's color with set stripecolor in your nanorc file.)
  • -K, --rawsequences โ€” Interprets escape sequences directly instead of asking ncurses to translate them ๐Ÿ› ๏ธ. If you need this to get some keys working, it means the terminfo terminal description being used doesn't fully match how your terminal actually behaves. That can happen when you ssh into a BSD machine, for example. Heads up: using this option disables nano's mouse support ๐Ÿ™ˆ.
  • -L, --nonewlines โ€” Doesn't automatically add a newline when a text doesn't end with one. Careful, bestie, this can make you save non-POSIX text files ๐Ÿ˜ฌ.
  • -M, --trimblanks โ€” Snips trailing whitespace from the wrapped line when automatic hard-wrapping happens or when text gets justified โœ‚๏ธ.
  • -N, --noconvert โ€” Disables automatic conversion of files from DOS/Mac format ๐Ÿšซ.
  • -O, --bookstyle โ€” When justifying, any line that starts with whitespace counts as the beginning of a paragraph, unless auto-indenting is on ๐Ÿ“–.
  • -P, --positionlog โ€” For the 200 most recent files, logs the last position of your cursor and puts it right back there when you reopen that file ๐Ÿ“.
  • -Q "regex", --quotestr="regex" โ€” Sets the regular expression used to match the quoting part of a line. The default value is "^([ \t]*([!#%:;>|}]|//))+". (Note that \t stands for an actual Tab.) This lets you rejustify blocks of quoted text when you're composing email, and rewrap blocks of line comments when you're writing source code ๐Ÿ’Œ.
  • -R, --restricted โ€” Restricted mode, so nano doesn't read or write any file you didn't specify on the command line ๐Ÿ”. That means: no reading or writing history files; no suspending; no spell checking; no appending to, prepending to, or saving a file under a different name if it already has one; and no making backup files. You can also activate restricted mode by invoking nano with any name that begins with 'r', like "rnano" ๐Ÿ•ต๏ธ.
  • -S, --softwrap โ€” Displays lines that are wider than the screen over multiple screen rows ๐ŸŒŠ. You can make this soft-wrapping happen at whitespace instead of rudely at the screen's edge by also using --atblanks.
  • -T number, --tabsize=number โ€” Sets the size (width) of a tab to number columns. The number has to be greater than 0. The default is 8 ๐Ÿ“.
  • -U, --quickblank โ€” Makes status-bar messages disappear after 1 keystroke instead of after 20 โฑ๏ธ. Heads up: option -c (--constantshow) overrides this. When --minibar or --zero is in effect, --quickblank makes a message disappear after 0.8 seconds instead of the default 1.5 seconds.
  • -V, --version โ€” Shows the current version number and exits ๐Ÿท๏ธ.
  • -W, --wordbounds โ€” Detects word boundaries differently by treating punctuation characters as part of a word ๐Ÿ”ค.
  • -X "characters", --wordchars="characters" โ€” Specifies which other characters (besides the normal alphanumeric ones) should count as part of a word ๐Ÿ’ซ. When you use this option, you probably want to leave out -W (--wordbounds).
  • -Y name, --syntax=name โ€” Picks the syntax highlighting to use from the ones defined in the nanorc files ๐ŸŒˆ.
  • -Z, --zap โ€” Lets an unmodified Backspace or Delete erase the marked region ๐Ÿ’ฅ. It erases the region instead of a single character, and it doesn't affect the cutbuffer.
  • -a, --atblanks โ€” When doing soft line wrapping, wraps lines at whitespace instead of always at the edge of the screen ๐Ÿซง.
  • -b, --breaklonglines โ€” Automatically hard-wraps the current line when it gets overlong โœ‚๏ธ. This is the opposite of -w (--nowrap), so whichever one you give last is the one that takes effect.
  • -c, --constantshow โ€” Constantly reports the cursor position on the status bar ๐Ÿ“. Heads up: this overrides option -U (--quickblank).
  • -d, --rebinddelete โ€” Interprets the Delete and Backspace keys differently so that both of them work properly ๐Ÿ”ง. Only use this option when, on your system, either Backspace acts like Delete or Delete acts like Backspace.
  • -e, --emptyline โ€” Doesn't use the line below the title bar, so it's left entirely blank ๐Ÿซฅ.
  • -f file, --rcfile=file โ€” Reads only this file for nano's options, instead of reading both the system-wide and the user's nanorc files ๐Ÿ“„.
  • -g, --showcursor โ€” Makes the cursor visible in the file browser (sitting on the highlighted item) and in the help viewer ๐Ÿ‘€. This is useful for braille users and people with poor vision ๐Ÿซถ.
  • -h, --help โ€” Shows a summary of the available command-line options and exits ๐Ÿ†˜.
  • -i, --autoindent โ€” Automatically indents a newly created line to the same number of tabs and/or spaces as the previous line ๐Ÿช„. If the previous line is the beginning of a paragraph, it uses the next line instead.
  • -j, --jumpyscrolling โ€” Scrolls the buffer contents per half-screen instead of per line ๐Ÿฆ˜.
  • -k, --cutfromcursor โ€” Makes the 'Cut Text' command (normally ^K) cut from your current cursor position to the end of the line, instead of cutting the entire line โœ‚๏ธ.
  • -l, --linenumbers โ€” bestie, this one shows line numbers down the left side of the text area. ๐Ÿ”ข Any line with an anchor also gets a little mark in the margin. ๐Ÿ“
  • -m, --mouse โ€” turns on mouse support, if your system can handle it. ๐Ÿ–ฑ๏ธ Once it's on, clicking places the cursor, a double click sets the mark, and clicks can run shortcuts. It works in the X Window System, and on the console when gpm is running. You can still select text by dragging while holding down the Shift key. ๐Ÿซถ
  • -n, --noread โ€” any name you give on the command line gets treated as a brand-new file. ๐Ÿ†• This lets nano write to named pipes: it opens with a blank buffer and only writes to the pipe when you save the "file". So you can use nano alongside something like gpg without ever dumping sensitive data onto disk first. ๐Ÿ” Iconic privacy behavior, honestly.
  • -o directory, --operatingdir=directory โ€” sets the operating directory. ๐Ÿ“‚ nano then sets things up in a way that's kind of like a chroot. ๐Ÿงš
  • -p, --preserve โ€” keeps the XOFF and XON sequences (^S and ^Q) alive so the terminal catches them, which means they stop and resume the output. ๐Ÿ›‘ Heads up though: option -/ (--modernbindings) overrides this one, so they can't both win. ๐Ÿ™…โ€โ™€๏ธ
  • -q, --indicator โ€” shows a "scrollbar" on the right side of the edit window. ๐Ÿ“œ It tells you where the viewport sits in the buffer and how much of the buffer the viewport is covering right now. ๐Ÿ‘€
  • -r number, --fill=number โ€” sets the target width for justifying and automatic hard-wrapping, measured in columns. ๐Ÿ“ If the number is 0 or less, wrapping happens at the screen width minus that many columns. That means the wrap point moves with the screen if you resize it, which is so cute. ๐Ÿฆ‹ The default is -8. โœจ
  • -s "program [argument ...]", --speller="program [argument ...]" โ€” use this to run your own spell checker and corrector instead of the built-in one, which calls hunspell(1) or spell(1). ๐Ÿ“
  • -t, --saveonexit โ€” saves a changed buffer without asking you first, when you exit with ^X. ๐Ÿ’พ No prompt, just vibes. ๐Ÿ˜Œ
  • -u, --unix โ€” saves files in Unix format by default. ๐Ÿง This overrides nano's usual habit of saving a file in whatever format it already had. (It does nothing if you also use --noconvert, so keep that in mind. ๐Ÿ™ƒ)
  • -v, --view โ€” view-only mode! ๐Ÿ‘€ You can look at the file but you can't edit it. It's read-only. You're still allowed to open other files for viewing, unless --restricted is given too. ๐Ÿšซโœ๏ธ
  • -w, --nowrap โ€” stops nano from automatically hard-wrapping the current line when it gets too long. ๐Ÿ™… This is the default, btw. (It's the opposite of -b (--breaklonglines), so whichever one you gave last is the one that actually takes effect. ๐Ÿ”„)
  • -x, --nohelp โ€” hides the two help lines at the bottom of the screen. ๐Ÿซฅ
  • -y, --afterends โ€” makes Ctrl+Right and Ctrl+Delete stop at the ends of words instead of the beginnings. ๐ŸŽฏ
  • -z, --listsyntaxes โ€” lists the names of the available syntaxes and then exits. ๐Ÿ“‹ Quick and to the point. ๐Ÿ’…
  • -!, --magic โ€” if neither the file's name nor its first line gives nano a clue, it'll try libmagic to figure out the right syntax. ๐Ÿ”ฎ
  • -@, --colonparsing โ€” okay this one is a whole glow-up. ๐Ÿช„ If a filename on the command line ends in a colon plus digits, and that exact filename doesn't exist, nano snips off the colon plus digits and treats them as a line number. If the trimmed name doesn't exist either, it does the whole thing again and treats the two numbers as a line number and a column number. ๐Ÿ“๐Ÿ“ But if the doubly trimmed name doesn't exist either, nano forgets all the trimming and just accepts your original filename as-is. ๐Ÿซถ To turn this colon parsing off for a particular file, put +1 or something similar before that filename.
  • -%, --stateflags โ€” shows some state flags in the top-right corner of the screen. ๐Ÿšฉ I means auto-indenting, M means the mark is on, L means hard-wrapping (breaking long lines), R means you're recording a macro, and S means soft-wrapping. ๐ŸŒˆ When the buffer has been modified, a star (*) shows up after the filename in the middle of the title bar. โญ
  • -_, --minibar โ€” hides the title bar and shows info about the current buffer at the bottom of the screen, in the status bar spot. ๐Ÿ“ On the left you get the filename, plus an asterisk if the buffer's been modified. On the right you get the current line and column number, the code of the character under the cursor (in Unicode format: U+xxxx), the same flags you'd see with --stateflags, and a percentage showing how far the cursor is through the file (linewise). ๐Ÿ“Š When you load or save a file, or switch between buffers, the number of lines in the buffer pops up after the filename. That number disappears on your next keystroke, or gets swapped for an [i/n] counter when multiple buffers are open. ๐Ÿ”ข The line plus column numbers and the character code only show up when --constantshow is used, and you can toggle them on and off with M-C. ๐Ÿ’œ The state flags only appear when --stateflags is used.
  • -0, --zero โ€” hides every bit of the interface (title bar, status bar, and help lines) so the whole terminal is just your buffer. ๐ŸŒŒ The status bar only shows up when there's an important message, and it vanishes after 1.5 seconds or on your next keystroke. โฑ๏ธ M-Z toggles the title bar plus status bar, and M-X toggles the help lines. ๐ŸŽ€
  • -/, --modernbindings โ€” uses key bindings like the ones most modern programs use, so it feels familiar. ๐Ÿ’– ^X cuts, ^C copies, ^V pastes, ^Z undoes, ^Y redoes, ^F searches forward, ^G searches next, ^S saves, ^O opens a file, ^Q quits, and (when your terminal permits) ^H shows help. โœจ Also: ^A sets the mark, ^R makes replacements, ^D searches previous, ^P shows the position, ^T goes to a line, ^W writes out a file, and ^E executes a command. ๐Ÿงš Just know this one overrides option -p (--preserve). ๐Ÿ™…โ€โ™€๏ธ

โœจ TOGGLES โœจ

Okay so several of the options above can be switched on and off while nano is still running, no restart needed! ๐Ÿ”„ For example, M-L toggles hard-wrapping of long lines, M-S toggles soft-wrapping, M-N toggles line numbers, M-M toggles the mouse, M-I toggles auto-indentation, and M-X toggles the help lines. ๐Ÿ’… For a full list, check the end of the ^G help text. ๐Ÿ“–

The M-X toggle is extra special, because it works in all menus except the help viewer and the linter. ๐Ÿ‘‘ All the other toggles only work in the main menu. ๐Ÿซถ


โœจ FILES โœจ

When you give --rcfile, nano reads just that one specified file for its options, syntaxes, and key bindings. ๐ŸŽ€ Without that option, nano reads two config files: first the system's nanorc (if it exists), then the user's nanorc (if it exists). The user one is either ~/.nanorc, or $XDG_CONFIG_HOME/nano/nanorc, or ~/.config/nano/nanorc, whichever nano finds first. ๐Ÿ” For more on what can go in those files, check out nanorc(5). ๐Ÿ“š

Also, /usr/share/nano/ and /usr/share/nano/extra/ are where you'll find the available syntax-coloring definitions. ๐ŸŒˆ


โœจ NOTES โœจ

Suspension is enabled by default and you can reach it with ^T^Z. โธ๏ธ If you'd rather have a plain ^Z suspend nano, add bind ^Z suspend main to your nanorc. ๐Ÿ™Œ

At a Yes-No prompt, ^Y works as "Yes", ^N as "No", and ^A as "All". ๐Ÿซถ These unlisted bindings work in any locale. ๐ŸŒ

Want to copy marked text from nano to the system's clipboard? Check out one of the examples in the nanorc(5) man page. ๐Ÿ“‹

If you don't specify an alternative spell checker command on the command line or in one of the nanorc files, nano checks the SPELL environment variable for one. ๐Ÿ”ค

๐Ÿ’€ Emergency file time. In some cases nano tries to dump the buffer into an emergency file. This mostly happens if nano receives a SIGHUP or SIGTERM or runs out of memory. ๐Ÿ˜ญ If the buffer didn't have a name already, it gets written into a file called nano.save. Otherwise, nano adds a .save suffix to the current filename. ๐Ÿซ  If an emergency file with that name already exists in the current directory, nano adds .save plus a number (e.g. .save.1) to the current filename so it stays unique. ๐Ÿงš In multibuffer mode, nano writes all open buffers to their own emergency files. ๐Ÿ’–

If you have any question about how to use nano in some specific situation, you can ask on help-nano@gnu.org. ๐Ÿ’Œ


โœจ BUGS โœจ

Keyboard macros can be recorded and played back correctly only on a terminal emulator, not on a Linux console (VT). ๐Ÿ™ˆ Why? Because the console doesn't distinguish modified from unmodified arrow keys by default. ๐Ÿ’€

Please report any other bugs you run into via: https://savannah.gnu.org/bugs/?group=nano. ๐Ÿ›

When nano crashes, it saves any modified buffers to emergency .save files. ๐Ÿซถ If you can reproduce the crash and you want a backtrace, define the environment variable NANO_NOCATCH. ๐Ÿ”ง


โœจ HOMEPAGE โœจ

https://nano-editor.org/ ๐Ÿก


โœจ SEE ALSO โœจ

nanorc(5) ๐Ÿ“š

/usr/share/doc/nano/ (or equivalent on your system) ๐ŸŒธ


Okay bestie, that's the whole thing! ๐ŸŽ€ Nano version 8.4, April 2025, and it's still iconic. ๐Ÿ’…โœจ

๐Ÿ“ฆ where this page comes from