NANO(1)
๐ 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\tstands 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 whengpmis 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 likegpgwithout 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 achroot. ๐ง-p,--preserveโ keeps the XOFF and XON sequences (^Sand^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 callshunspell(1)orspell(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--restrictedis 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โ makesCtrl+RightandCtrl+Deletestop 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 trylibmagicto 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+1or something similar before that filename.-%,--stateflagsโ shows some state flags in the top-right corner of the screen. ๐ฉImeans auto-indenting,Mmeans the mark is on,Lmeans hard-wrapping (breaking long lines),Rmeans you're recording a macro, andSmeans 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--constantshowis used, and you can toggle them on and off withM-C. ๐ The state flags only appear when--stateflagsis 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-Ztoggles the title bar plus status bar, andM-Xtoggles the help lines. ๐-/,--modernbindingsโ uses key bindings like the ones most modern programs use, so it feels familiar. ๐^Xcuts,^Ccopies,^Vpastes,^Zundoes,^Yredoes,^Fsearches forward,^Gsearches next,^Ssaves,^Oopens a file,^Qquits, and (when your terminal permits)^Hshows help. โจ Also:^Asets the mark,^Rmakes replacements,^Dsearches previous,^Pshows the position,^Tgoes to a line,^Wwrites out a file, and^Eexecutes 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 aSIGHUPorSIGTERMor runs out of memory. ๐ญ If the buffer didn't have a name already, it gets written into a file callednano.save. Otherwise, nano adds a.savesuffix to the current filename. ๐ซ If an emergency file with that name already exists in the current directory, nano adds.saveplus 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 โจ
โจ 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
- ubuntu questing: nano 8.4-1ubuntu0.1 ยท GPL-3.0-or-later
- Copyright (C) 1999-2011, 2013-2025 Free Software Foundation, Inc
- ๐ girlified by anthropic/claude-haiku-5.5 on : a language model's rewrite of the original, under its terms