info > nano(1)

šŸ“˜ The GNU nano text editor

This manual documents GNU 'nano', version 6.2.

šŸ“‹ Menu

1ļøāƒ£ Introduction

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

The original goal for 'nano' was to be a complete bug-for-bug emulation of Pico. But currently the goal is to be as compatible as is reasonable while offering a superset of Pico's functionality. See Pico Compatibility for more details on how 'nano' and Pico differ.

Starting with version 4.0, 'nano' no longer hard-wraps an overlong line by default. It further uses linewise scrolling by default, and by default includes the line below the title bar into the editing area. If you want the old, Pico behavior back, you can use the following options: --breaklonglines, --jumpyscrolling, and --emptyline (or -bje).

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

For background information see https://nano-editor.org/.

šŸš€ Quick Reference

Use Case Command Description
šŸ“‚ Open a file nano [FILE] Open FILE for editing; if omitted, start with a blank buffer.
šŸ’¾ Save a file ^O Write out (save) the current buffer, prompting for a filename if needed.
🚪 Exit nano ^X Exit the editor; prompts to save if buffer modified.
šŸ” Search forward ^W Start a forward search for text in the current buffer.
šŸ”„ Replace text ^\ or M-R Interactively replace occurrences of a search string.
āœ‚ļø Cut a line ^K Cut the current line (or marked region) and store in cutbuffer.
šŸ“‹ Paste ^U Paste the contents of the cutbuffer at the cursor position.
šŸ“ Show cursor position ^C Display the current line, column, and character position.
ā“ Help ^G Open the built-in help viewer.
šŸ”™ Undo M-U Undo the last text action.
šŸ”œ Redo M-E Redo the last undone action.

2ļøāƒ£ Invoking

The usual way to invoke 'nano' is:

nano [FILE]

But it is also possible to specify one or more options (see Command-line Options), and to edit several files in a row.

Additionally, the cursor can be put on a specific line of a file by adding the line number with a plus sign before the filename, and even in a specific column by adding it with a comma. (Negative numbers count from the end of the file or line.) The cursor can also be put 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 caused to be interpreted as a regular expression by inserting a c and/or r after the plus sign. These search modes can be explicitly disabled by using the uppercase variant of those letters: C and/or R. When the string contains spaces, it needs to be enclosed in quotes. A more complete command synopsis thus is:

nano [OPTION]... [[+LINE[,COLUMN]|+[crCR](/|?)STRING] FILE]...

Normally, however, you set your preferred options in a 'nanorc' file (see Nanorc Files). And when using set positionlog (making 'nano' remember the cursor position when you close a file), you will rarely need to specify a line number.

As a special case: when instead of a filename a dash is given, 'nano' will read data from standard input. This means you can pipe the output of a command straight into a buffer, and then edit it.

3ļøāƒ£ Editor Basics

3.1 šŸ–„ļø Screen Layout

The default screen of 'nano' consists of four areas. From top to bottom these are: the title bar, the edit window, the status bar, and two help lines.

The title bar consists of three sections: left, center and right. The section on the left displays the version of 'nano' being used. The center section displays the current filename, or "New Buffer" if the file has not yet been named. The section on the right displays "Modified" if the file has been modified since it was last saved or opened.

The status bar is the third line from the bottom of the screen. It shows important and informational messages. Any error messages that occur from using the editor will appear on the status bar. Any questions that are asked of the user will be asked on the status bar, and any user input (search strings, filenames, etc.) will be input on the status bar.

The two help lines at the bottom of the screen show some of the most essential functions of the editor.

3.2 āŒØļø Entering Text

'nano' is a "modeless" editor. This means that all keystrokes, with the exception of Control and Meta sequences, enter text into the file being edited.

Characters not present on the keyboard can be entered in two ways:

For example, typing Esc Esc 2 3 4 will enter the character "eĢ‚" -- useful when writing about a French party. Typing M-V 0 0 2 2 c 4 will enter the symbol "✦", a little diamond.

3.3 āŒØļø Commands

Commands are given by using the Control key (Ctrl, shown as ^) or the Meta key (Alt or Cmd, shown as M-).

If for some reason on your system the combinations with Ctrl or Alt do not work, you can generate them by using the Esc key. A control-key sequence is generated by pressing the Esc key twice and then pressing the desired key, and a meta-key sequence by pressing the Esc key once and then pressing the desired key.

3.4 āœ‚ļø The Cutbuffer

Text can be cut from a file a whole line at a time with ^K. The cut line is stored in the cutbuffer. Consecutive strokes of ^K will add each cut line to this buffer, but a ^K after any other keystroke will overwrite the entire cutbuffer.

The contents of the cutbuffer can be pasted at the current cursor position with ^U.

A line of text can be copied into the cutbuffer (without cutting it) with M-6.

3.5 šŸ“Œ The Mark

Text can be selected by first 'setting the Mark' with ^6 or M-A and then moving the cursor to the other end of the portion to be selected. The selected portion of text will be highlighted. This selection can now be cut or copied in its entirety with a single ^K or M-6. Or the selection can be used to limit the scope of a search-and-replace (^\) or spell-checking session (^T^T).

On some terminals, text can be selected also by holding down Shift while using the cursor keys. Holding down the Ctrl or Alt key too will increase the stride. Such a selection is cancelled upon any cursor movement where Shift isn't held.

Cutting or copying selected text toggles off the mark automatically. If needed, it can be toggled off manually with another ^6 or M-A.

3.6 šŸ” Search and Replace

One can search the current buffer for the occurrence of any string with the Search command (default key binding: ^W). The default search mode is forward, case-insensitive, and for literal strings. But one can search backwards by pressing M-B, search case sensitively with M-C, and interpret regular expressions in the search string with M-R.

A regular expression in a search string always covers just one line; it cannot span multiple lines. And when replacing (with ^\ or M-R) the replacement string cannot contain a newline (LF).

3.7 šŸ–±ļø Using the Mouse

When mouse support has been configured and enabled, a single mouse click places the cursor at the indicated position. Clicking a second time in the same position toggles the mark. Clicking in the two help lines executes the selected shortcut. To be able to select text with the left button, or paste text with the middle button, hold down the Shift key during those actions.

The mouse will work in the X Window System, and on the console when gpm is running.

3.8 āš“ Anchors

With M-Ins you can place an anchor (a kind of temporary bookmark) at the current line. With M-PgUp and M-PgDn you can jump to an anchor in the backward/forward direction. This jumping wraps around at the top and bottom.

When a line with an anchor is removed, the line where the cursor ends up inherits the anchor. After performing an operation on the entire buffer (like formatting it, piping it through a command, or doing an external spell check on it), any anchors that were present are gone. And when you close the buffer, all its anchors simply disappear; they are not saved.

Anchors are visualized in the margin when line numbers are activated.

3.9 āš ļø Limitations

The recording and playback of keyboard macros works correctly only on a terminal emulator, not on a Linux console (VT), because the latter does not by default distinguish modified from unmodified arrow keys.

4ļøāƒ£ The Help Viewer

The built-in help in 'nano' is available by pressing ^G. It is fairly self-explanatory. It documents the various parts of the editor and the available keystrokes. Navigation is via the ^Y (Page Up) and ^V (Page Down) keys. ^X exits from the help viewer.

5ļøāƒ£ The File Browser

When in the Read-File (^R) or Write-Out menu (^O), pressing ^T will invoke the file browser. Here, one can navigate directories in a graphical manner in order to find the desired file.

Basic movement in the file browser is accomplished with the arrow and other cursor-movement keys. More targeted movement is accomplished by searching, via ^W or w, or by changing directory, via ^_ or g. The behavior of the Enter key (or s) varies by what is currently selected. If the currently selected object is a directory, the file browser will enter and display the contents of the directory. If the object is a file, this filename and path are copied to the status bar, and the file browser exits.

6ļøāƒ£ Command-line Options

'nano' takes the following options from the command line:

7ļøāƒ£ Feature Toggles

Toggles allow you to change certain aspects of the editor while you are editing, aspects that you would normally specify via command-line options or nanorc options. Each toggle can be flicked via a Meta-key combination -- the 'Meta' key is normally the 'Alt' key (see Commands for more details). The following global toggles are available:

8ļøāƒ£ Nanorc Files

Nanorc files can be used to configure 'nano' to your liking without using command-line options. During startup 'nano' will normally read two files: first the system-wide file, /etc/nanorc (the exact path may be different on your system), and then the user-specific file, either ~/.nanorc or $XDG_CONFIG_HOME/nano/nanorc or .config/nano/nanorc, whichever exists first. However, if --rcfile is given, 'nano' will skip the above files and will read just the specified settings file.

A nanorc file can contain set and unset commands for various options (see Settings). It can also contain commands that define syntax highlighting (see Syntax Highlighting) and commands that rebind keys (see Rebinding Keys). Each command should be on a separate line, and all commands should be written in lowercase.

Options that do not take an argument are unset by default. So using the unset command is only needed when wanting to override a setting from the system's nanorc file in your own nanorc. Options that take an argument cannot be unset, but can be assigned the empty string.

Any command-line option overrides its nanorc setting, of course.

Quotes inside the CHARACTERS parameters below should not be escaped. The last double quote on the line will be seen as the closing quote.

8.1 āš™ļø Settings

The supported settings in a nanorc file are:

8.2 šŸŽØ Syntax Highlighting

Coloring the different syntactic elements of a file is done via regular expressions (see the color command below). This is inherently imperfect, because regular expressions are not powerful enough to fully parse a file. Nevertheless, regular expressions can do a lot and are easy to make, so they are a good fit for a small editor like 'nano'.

See /usr/share/nano/ and /usr/share/nano/extra/ for the syntax-coloring definitions that are available out of the box.

All regular expressions in 'nano' are POSIX extended regular expressions (ERE). This means that ., ?, *, +, ^, $, and several other characters are special. The period . matches any single character, ? means the preceding item is optional, * means the preceding item may be matched zero or more times, + means the preceding item must be matched one or more times, ^ matches the beginning of a line, and $ the end, \< matches the start of a word, and \> the end, and \s matches a blank. It also means that lookahead and lookbehind are not possible. A complete explanation can be found in the manual of GNU grep: info grep regular.

A separate syntax can be defined for each kind of file via the following commands in a nanorc file:

8.3 šŸ”„ Rebinding Keys

Key bindings can be changed via the following three commands in a nanorc file:

The format of 'key' should be one of:

Rebinding ^M (Enter) or ^I (Tab) is probably not a good idea. Rebinding ^[ (Esc) is not possible, because its keycode is the starter byte of Meta keystrokes and escape sequences. Rebinding any of the dedicated cursor-moving keys (the arrows, Home, End, PageUp and PageDown) is not possible. On some terminals it's not possible to rebind ^H (unless --raw is used) because its keycode is identical to that of the Backspace key.

Valid names for the 'function' to be bound are:

Valid names for 'menu' are:

9ļøāƒ£ Pico Compatibility

'nano' emulates Pico quite closely, but there are some differences between the two editors:

šŸ”Ø Building and its Options

Building 'nano' from source is straightforward if you are familiar with compiling programs with autoconf support:

tar -xf nano-x.y.tar.gz
cd nano-x.y
./configure
make
make install

The possible options to ./configure are:

nano(1)
šŸ“˜ The GNU nano text editor šŸ“‹ Menu 1ļøāƒ£ Introduction šŸš€ Quick Reference 2ļøāƒ£ Invoking 3ļøāƒ£ Editor Basics
3.1 šŸ–„ļø Screen Layout 3.2 āŒØļø Entering Text 3.3 āŒØļø Commands 3.4 āœ‚ļø The Cutbuffer 3.5 šŸ“Œ The Mark 3.6 šŸ” Search and Replace 3.7 šŸ–±ļø Using the Mouse 3.8 āš“ Anchors 3.9 āš ļø Limitations
4ļøāƒ£ The Help Viewer 5ļøāƒ£ The File Browser 6ļøāƒ£ Command-line Options 7ļøāƒ£ Feature Toggles 8ļøāƒ£ Nanorc Files
8.1 āš™ļø Settings 8.2 šŸŽØ Syntax Highlighting 8.3 šŸ”„ Rebinding Keys
9ļøāƒ£ Pico Compatibility šŸ”Ø Building and its Options

Generated by phpman v4.9.26-1-g511901d · Markdown · JSON · MCP Author: Che Dong Under GNU General Public License
2026-08-05 23:07 @216.73.216.192
CrawledBy Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)
Valid XHTML 1.0 Transitional!Valid CSS!
Enhanced by LLM: deepseek-v4-flash / taotoken.net / www.chedong.com - original format

^_top_^