NANO(1)

okay bestie, sit down, hydrate, put your phone on do-not-disturb ๐Ÿ’– โ€” because today we're reading the manual page for nano(1), from the General Commands Manual (section 1, the "commands you type in a shell" section ๐Ÿ’…). she's an icon, she's free software, and she has opinions about your whitespace. let's get into it.


โœจ NAME โœจ

nano โ€” Nano's ANOther text editor, inspired by Pico ๐ŸŽ€


โœจ SYNOPSIS โœจ


๐Ÿฆ‹ DESCRIPTION ๐Ÿฆ‹

nano is a small and friendly text editor. no cap, that's literally the whole vibe. she copies the look and feel of Pico, but she's free software, and she implements a few features that Pico simply does not have, such as: opening multiple files, scrolling per line, undo/redo, syntax coloring, line numbering, and soft-wrapping overlong lines. periodt. ๐Ÿ’…

When you give a filename on the command line, you can park the cursor on a specific line by putting the line number with a plus sign (+) before the filename โ€” and even drop it into a specific column by adding that with a comma. Negative numbers count from the end of the file or line. yes bestie, backwards math, it's giving time travel ๐Ÿ•ฐ๏ธ.

You can also put the cursor on the first or last occurrence of a specific string by specifying that string after +/ or +? before the filename. The string can be made case sensitive and/or made to be interpreted as a regular expression by inserting c and/or r after the + sign. Those search modes can be explicitly disabled by using the uppercase variants of those letters: C and/or R. When the string contains spaces, it needs to be wrapped in quotes. example time โ€” to open a file at the first occurrence of the word Foo, you'd do:

nano +c/Foo file

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


๐ŸŒˆ NOTICES ๐ŸŒˆ

Since version 9.0, all lines are scrolled horizontally together (when the cursor approaches the edge), by just the amount needed, instead of scrolling only the current line by a large step. If you prefer the old behavior, you can use --solo on the command line or set solosidescroll in your nanorc.

Also since version 9.0, the keystrokes M-< and M-> have been reassigned to the scrollleft and scrollright functions. If you want those keystrokes to do what they did before version 9.0, add these two lines at the end of your nanorc file:

bind M-< prevbuf main
bind M-> nextbuf main

Since version 8.0, to be newcomer friendly, ^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 want those keystrokes to do what they did before version 8.0, add the following four lines at the end of your nanorc file:

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

๐Ÿ’… EDITING ๐Ÿ’…

Entering text and moving around in a file is straightforward: you type the letters and you use the normal cursor movement keys. commands are entered by using the Control (^) and the Alt or Meta (M-) keys. Typing ^K deletes the current line and puts it in the cutbuffer. Consecutive ^Ks put all deleted lines together in the cutbuffer. Any cursor movement โ€” or executing any other command โ€” causes the next ^K to overwrite the cutbuffer. A ^U pastes the current contents of the cutbuffer at the current cursor position. ๐Ÿ“

When a more precise piece of text needs to be cut or copied, you can mark its start with ^6, move the cursor to its end (the marked text is highlighted โœจ), and then 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, text can also be selected by holding down Shift while using the arrow keys. Holding down the Ctrl or Alt key too increases the stride. Any cursor movement without Shift being held cancels such a 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 (concluded with Space or Enter when there are fewer than six digits). A literal control code (except ^J) can be inserted by typing M-V followed by the pertinent keystroke. ๐Ÿงš

The two lines at the bottom of the screen show some important commands; the built-in help (^G) lists all the available ones. The default key bindings can be changed via a nanorc file โ€” see nanorc(5).

With ^S^X you can save the buffer and exit from nano. ๐Ÿซก


๐Ÿ‘‘ OPTIONS ๐Ÿ‘‘

  • -A, --smarthome โ€” makes the Home key smarter. when Home is pressed anywhere except the very beginning of non-whitespace characters on a line, the cursor jumps to that beginning (either forwards or backwards). If the cursor is already at that position, it jumps to the true beginning of the line.
  • -B, --backup โ€” when saving a file, back up the previous version of it, using the current filename suffixed with a tilde (~).
  • -C directory, --backupdir=directory โ€” don't just make and keep one backup file, make and keep a *uniquely numbered one every single time a file is saved โ€” when backups are enabled (-B). Those uniquely numbered files are stored in the specified *directory.
  • -D, --boldtext โ€” for the interface, use bold instead of reverse video. This can be overridden 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 โ€” convert each typed tab to spaces โ€” to the number of spaces that a tab at that position would take up. (Note: pasted tabs are not converted. ๐Ÿ™ˆ)
  • -F, --newbuffer โ€” read a file into a new buffer by default. (The old form of this option, --multibuffer, is deprecated.)
  • -G, --locking โ€” use vim-style file locking when editing files.
  • -H, --historylog โ€” save the last hundred search strings and replacement strings and executed commands, so they can be easily reused in later sessions.
  • -I, --ignorercfiles โ€” don't look at the system's nanorc nor at the user's nanorc.
  • *-J *number, --guidestripe=number โ€” draw a vertical stripe at the given column, to help judge the width of the text. (The color of the stripe can be changed with set stripecolor in your nanorc file.)
  • -K, --rawsequences โ€” interpret escape sequences directly, instead of asking ncurses to translate them. (If you need this option to get some keys to work properly, it means that the terminfo terminal description that is used does not fully match the actual behavior of your terminal. This can happen when you ssh into a BSD machine, for example.) Using this option disables nano's mouse support. ๐Ÿ’€
  • -L, --nonewlines โ€” don't automatically add a newline when a text does not end with one. (This can cause you to save non-POSIX text files. ๐Ÿ˜ญ)
  • -M, --trimblanks โ€” snip trailing whitespace from the wrapped line when automatic hard-wrapping occurs or when text is justified.
  • -N, --noconvert โ€” disable automatic conversion of files from DOS format.
  • -O, --bookstyle โ€” when justifying, treat any line that starts with whitespace as the beginning of a paragraph (unless auto-indenting is on).
  • -P, --positionlog โ€” for the 200 most recent files, log the last position of the cursor, and place it at that position again upon reopening such a file. Also save and restore the positions of any anchors.
  • *-Q *"regex", --quotestr="regex" โ€” set the regular expression for matching the quoting part of a line. The default value is "^([ \t]*([!#%:;>|}]|//))+". (Note that \t stands for an actual Tab.) This makes it possible to rejustify blocks of quoted text when composing email, and to rewrap blocks of line comments when writing source code.
  • -R, --restricted โ€” read and write only the file (or files) specified on the command line. This means: don't read or write the history files; don't allow suspending; don't allow spell checking; don't allow executing any command in the shell; don't allow the current buffer to be saved under a different name; don't allow appending or prepending to any file; and don't make backup files.

As an exception, before the specified file or files, the nanorc files are read, to allow customization. If customization should not be allowed, use option -I (--ignorercfiles) as well.

When no file is specified on the command line, restricted mode allows you to save the contents that you type into the new buffer under any name, except that existing files may not be overwritten. If the places where this new file may be created should be limited, then use option -o (--operatingdir) as well.

Restricted mode can also be activated by invoking nano with a name beginning with 'r' (for example: rnano).

  • -S, --softwrap โ€” display over multiple screen rows lines that exceed the screen's width. (You can make this soft-wrapping occur at whitespace instead of rudely at the screen's edge, by using also --atblanks.)
  • -T number, --tabsize=number โ€” set the size (width) of a tab to number columns. The value of number must be **greater than 0. The default value is 8.
  • -U, --quickblank โ€” make status-bar messages disappear after 1 keystroke instead of after 20. Note that option -c (--constantshow) overrides this. When option --minibar or --zero is in effect, --quickblank makes a message disappear after 0.8 seconds instead of after the default 1.5 seconds.
  • -V, --version โ€” show the current version number and exit.
  • -W, --wordbounds โ€” detect word boundaries differently by treating punctuation characters as part of a word.
  • *-X *"characters", --wordchars="characters" โ€” specify which other characters (besides the normal alphanumeric ones) should be considered as part of a word. When using this option, you probably want to omit -W (--wordbounds).
  • *-Y *name, --syntax=name โ€” specify the name of the syntax highlighting to use from among the ones defined in the nanorc files.
  • -Z, --zap โ€” let an unmodified Backspace or Delete erase the marked region (instead of a single character, and without affecting the cutbuffer).
  • -a, --atblanks โ€” when doing soft line wrapping, wrap lines at whitespace instead of always at the edge of the screen.
  • -b, --breaklonglines โ€” automatically hard-wrap the current line when it becomes overlong, that is: when it becomes wider than the value given with -r (--fill). The default value for -r is the terminal's width minus eight. (This option is the opposite of -w (--nowrap) โ€” the last one given takes effect.)
  • -c, --constantshow โ€” bestie, this one keeps the cursor position on the status bar at all times. ๐Ÿ’– Heads up tho: it overrides -U (--quickblank), so you can't have both vibes.
  • -d, --rebinddelete โ€” makes nano treat the Delete and Backspace keys differently so that both of them actually do their job properly. ๐Ÿ™ˆ Only reach for this when your system is being weird โ€” like, either Backspace acts like Delete or Delete acts like Backspace. That's the only situation fr fr.
  • -e, --emptyline โ€” do not use the line below the title bar. Just leave it entirely blank. minimalism core. โœจ
  • -f file, --rcfile=file โ€” read only this one file for setting nano's options, instead of reading both the system-wide nanorc and your personal nanorc. One file, no distractions. ๐ŸŽ€
  • -g, --showcursor โ€” make the cursor visible in the file browser (it sits on the highlighted item) and in the help viewer. Super useful for braille users and people with poor vision. ๐Ÿซถ
  • -h, --help โ€” show a lil summary of the available command-line options and then exit. the classic.
  • -i, --autoindent โ€” new lines get auto-indented to match the same number of tabs and/or spaces as the previous line. (Or as the next line if the previous line is the beginning of a paragraph.) ๐Ÿ’… coding girlies, this one's for you.
  • -j, --jumpyscrolling โ€” scroll the buffer contents per half-screen instead of per line. Chaotic? a little. Effective? yes. โญ
  • -k, --cutfromcursor โ€” makes the 'Cut' command (^K) cut from the cursor to end-of-line instead of cutting the whole entire line. And when the cursor is already sitting at end-of-line? Then the linebreak itself gets cut. โœ‚๏ธ
  • -l, --linenumbers โ€” display line numbers to the left of the text area. (Any line with an anchor additionally gets a mark in the margin. ๐Ÿ‘€)
  • -m, --mouse โ€” enable mouse support. Here's the whole vibe check, bestie: a click in the edit window places the cursor, two clicks at the same spot toggles the mark, a click in the help lines executes the touched shortcut, a click in the "scrollbar" scrolls the buffer to roughly that position, and rolling the wheel scrolls the viewport instead of moving the cursor. ๐Ÿ–ฑ๏ธ (The mouse works in the X Window System, and on the console when gpm is running. Under X, text can still be selected through dragging by holding down Shift.)
  • -n, --noread โ€” treat any name given on the command line as a new file. This is the slay that lets nano write to named pipes: it starts with a blank buffer, and writes to the pipe when the user saves the "file". This way nano can be used as an editor in combination with, for instance, gpg โ€” without having to write sensitive data to disk first. ๐Ÿ”ฅ security girlies rise.
  • -o directory, --operatingdir=directory โ€” change to the given directory, and allow reading and writing files only in this directory and its subdirectories. ๐Ÿ  stay in your lane (affectionate).
  • -p, --preserve โ€” preserve the XOFF and XON sequences (^S and ^Q) so that they get caught by the terminal (stopping and resuming the output). Note that option -/ (--modernbindings) overrides this. ๐Ÿ’œ
  • -q, --indicator โ€” display a "scrollbar" on the righthand side of the edit window. It shows the position of the viewport in the buffer and how much of the buffer is covered by the viewport. ๐Ÿ‘‘
  • -r number, --fill=number โ€” set the target width for justifying and automatic hard-wrapping at this number of columns. If the value is 0 or less, wrapping occurs at the width of the screen minus number columns โ€” which means the wrap point can vary along with the width of the screen if the screen gets resized. The default value is -8. ๐Ÿ“
  • -s "program [argument ...]", --speller="program [argument ...]" โ€” use this command to perform spell checking and correcting, instead of using the built-in corrector that calls hunspell(1) or spell(1). ๐Ÿ“ spelling era.
  • -t, --saveonexit โ€” save a changed buffer without prompting (when exiting with ^X). no more "are you sure" jumpscare. ๐Ÿ’€
  • -u, --unix โ€” save a file by default in Unix format. This overrides nano's default behavior of saving a file in the format that it had. (This option has no effect when you also use --noconvert.)
  • -v, --view โ€” just view the file and disallow editing: read-only mode. This mode allows the user to open also other files for viewing โ€” unless --restricted is given too. ๐Ÿฆ‹ look but don't touch.
  • -w, --nowrap โ€” do not automatically hard-wrap the current line when it becomes overlong. This is the default. (This option is the opposite of -b (--breaklonglines) โ€” the last one given takes effect.) ๐Ÿงš
  • -x, --nohelp โ€” don't show the two help lines at the bottom of the screen. bye bestie ๐Ÿ‘‹
  • -y, --afterends โ€” make Ctrl+Right and Ctrl+Delete stop at word ends instead of beginnings. ๐ŸŒˆ
  • -z, --listsyntaxes โ€” list the names of the available syntaxes and exit. โญ
  • -!, --magic โ€” when neither the file's name nor its first line give a clue, try using libmagic to determine the applicable syntax. ๐Ÿ”ฎ
  • -@, --colonparsing โ€” when a filename given on the command line ends in a colon plus digits and this filename does not exist, then snip the colon plus digits and understand the digits as a line number. If the trimmed filename does not exist either, then repeat the process and understand the obtained two numbers as line and column number. But if the doubly trimmed filename does not exist either, then forget the trimming and accept the original filename as is. To disable this colon parsing for some file, use +1 or similar before the relevant filename. ๐Ÿ˜ญ okay that's a lot but it's all important.
  • -%, --stateflags โ€” use the top-right corner of the screen for showing some state flags: I when auto-indenting, M when the mark is on, L when hard-wrapping (breaking long lines), R when recording a macro, and S when soft-wrapping. When the buffer is modified, a star (*) is shown after the filename in the center of the title bar. โœจ dashboard energy.
  • -_, --minibar โ€” suppress the title bar and instead show information about the current buffer at the bottom of the screen, in the space for the status bar. In this "mini bar" the filename is shown on the left, followed by an asterisk if the buffer has been modified. On the right are displayed the current line and column number, the code of the character under the cursor (in Unicode format: U+xxxx), the same flags as are shown by --stateflags, and a percentage that expresses how far the cursor is into the file (linewise). When a file is loaded or saved, and also when switching between buffers, the number of lines in the buffer is displayed after the filename. This number is cleared upon the next keystroke, or replaced with an [i/n] counter when multiple buffers are open. The line plus column numbers and the character code are displayed only when --constantshow is used, and can be toggled on and off with M-C. The state flags are displayed only when --stateflags is used. ๐Ÿ‘‘
  • -0, --zero โ€” hide all elements of the interface (title bar, status bar, and help lines) and use all rows of the terminal for showing the contents of the buffer. The status bar appears only when there is a significant message, and disappears after 1.5 seconds or upon the next keystroke. With M-Z the title bar plus status bar can be toggled. With M-X the help lines. ๐Ÿซถ fully immersive mode.
  • -1, --solosidescroll โ€” when the cursor approaches the right edge of the edit window, scroll only the current line sideways by a large amount, instead of scrolling all visible lines sideways by just the amount needed to keep the cursor in view. This latter whole-window smooth sideways scrolling is the new default behavior. The single-line jerky sideways scrolling enabled by this option was the old behavior โ€” the only behavior that nano knew. ๐Ÿ’€ vintage.
  • -/, --modernbindings โ€” use key bindings similar to the ones that most modern programs use: ^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 the terminal permits) ^H shows help. Furthermore, ^A sets the mark, ^B searches backward, ^D searches previous, ^R makes replacements, ^P shows the position, ^T goes to a line, ^W writes out a file, and ^E executes a command. Note that this option overrides option -p (--preserve). ๐ŸŒธ

๐Ÿ”„ TOGGLES ๐Ÿ”„

Several of the above options can be switched on and off also while nano is running, bestie. It's giving live editing. For example, M-L toggles the hard-wrapping of long lines, M-S toggles soft-wrapping, M-N toggles line numbers, M-M toggles the mouse, M-I auto-indentation, and M-X the help lines. See at the end of the ^G help text for a complete list. ๐Ÿ“

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


๐Ÿ“ FILES ๐Ÿ“

When --rcfile is given, nano reads just the specified file for setting its options and syntaxes and key bindings. Without that option, nano reads two configuration files: first the system's nanorc (if it exists), and then the user's nanorc (if it exists) โ€” either ~/.nanorc or $XDG_CONFIG_HOME/nano/nanorc or ~/.config/nano/nanorc, whichever is encountered first. See nanorc(5) for more information on the possible contents of those files. ๐ŸŽ€

See /usr/share/nano/ and /usr/share/nano/extra/ for available syntax-coloring definitions. ๐ŸŒˆ


๐Ÿšช EXIT STATUS ๐Ÿšช

  • 0 โ€” The editor finished normally. slay. โœจ
  • 1 โ€” An invalid option or option argument was given. ๐Ÿ’€
  • 2 โ€” The last open buffer was discarded (with ^O^Q or ^X^Q). ๐Ÿ˜ญ

๐Ÿ’– NOTES ๐Ÿ’–

Okay bestie, story time โ€” these are the little things that aren't in the option list but that you will want to know.

Suspension is on by default, and you get to it with ^T^Z. Yes, that's really the combo. If you're out here wanting a plain ^Z to suspend like it's any other program, you gotta tell nano yourself, like this:

bind ^Z suspend main

...and you'd put that in your nanorc. No cap. ๐Ÿซถ


At a Yes-No prompt, you have shortcut keys for the vibes: ^Y is for "Yes", ^N is for "No", and ^A is for "All". And when you're exiting, ^Q is for "Quit with error". These bindings aren't listed anywhere in the menus, but they work in any locale. iykyk. โœจ

When you wanna copy marked text out of nano and into the system's clipboard, go look at one of the examples in the nanorc(5) man page. It's giving DIY but it works, bestie. ๐Ÿ’…

If you haven't specified an alternative spell checker command on the command line, and you haven't put one in any of your nanorc files either, nano will check the SPELL environment variable for one. So like, set SPELL and nano's gotchu. ๐ŸŽ€


๐Ÿšจ Emergency Files (this is the important one) ๐Ÿšจ

Some situations make nano try to dump the buffer into an emergency file. This mostly happens if nano gets a SIGHUP or SIGTERM, or if it runs out of memory. ๐Ÿ˜ญ

Here's the tea on how it names them:

  • If the buffer didn't have a name already, it writes the buffer into a file named nano.save.
  • Otherwise, it adds a .save suffix to the current filename.
  • If an emergency file with that name already exists in the current directory, it adds ".save" plus a number to the current filename so it stays unique โ€” for example: ".save.1".
  • When multiple buffers are open, nano writes each modified buffer to its respective emergency file. One per buffer, bestie, no mixing. ๐Ÿ’œ
Lowkey the emergency files are your besties. Don't delete them until you've checked them. ๐Ÿ™ˆ

The complete manual is maintained in Texinfo format. You can read it with info nano, or find it online at https://nano-editor.org/dist/latest/nano.html. Go forth and read, queen. ๐Ÿ‘‘

If you've got any question about how to use nano in some specific situation, you can ask on help-nano@gnu.org. The real ones answer there. ๐Ÿ’Œ


๐Ÿ”ฅ BUGS ๐Ÿ”ฅ

The recording and playback of keyboard macros works correctly only on a terminal emulator, not on a Linux console (VT). Why? Because the console doesn't by default distinguish modified from unmodified arrow keys. So the macro life is emulator-only, I don't make the rules. ๐Ÿ’€

Please report any other bugs that you encounter via:

https://savannah.gnu.org/bugs/?group=nano

When nano crashes, it saves any modified buffers to emergency .save files. And if you're able to reproduce the crash and you want to get a backtrace, define the environment variable NANO_NOCATCH. That's the secret handshake. ๐ŸŒธ


๐Ÿ  HOMEPAGE ๐Ÿ 

https://nano-editor.org/

That's the house. Go say hi. โญ


๐Ÿ‘€ SEE ALSO ๐Ÿ‘€

  • nanorc(5) โ€” the config file's whole lore, and the place to find those clipboard examples. ๐Ÿ“‹
  • /usr/share/doc/nano/ (or equivalent on your system) โ€” the docs, chillin' on your machine. ๐Ÿ“

And that's the whole page, bestie!! ๐Ÿฆ‹ You now know nano better than half the people who claim to know nano. Proud of you fr fr. ๐Ÿ’– โœจ

This was GNU nano 9.3, dated October 2026 โ€” yeah, this is NANO(1), and she ate. Periodt. ๐Ÿ’…๐Ÿ‘‘

๐Ÿ“ฆ where this page comes from