Debian Codegraph @

upstream/fedora-44/man1/nano.1

raw
1 .\" Copyright (C) 1999-2011, 2013-2026 Free Software Foundation, Inc.
2 .\"
3 .\" This document is dual-licensed. You may distribute and/or modify it
4 .\" under the terms of either of the following licenses:
5 .\"
6 .\" * The GNU General Public License, as published by the Free Software
7 .\" Foundation, version 3 or (at your option) any later version. You
8 .\" should have received a copy of the GNU General Public License
9 .\" along with this program. If not, see
10 .\" <https://www.gnu.org/licenses/>.
11 .\"
12 .\" * The GNU Free Documentation License, as published by the Free
13 .\" Software Foundation, version 1.2 or (at your option) any later
14 .\" version, with no Invariant Sections, no Front-Cover Texts, and no
15 .\" Back-Cover Texts. You should have received a copy of the GNU Free
16 .\" Documentation License along with this program. If not, see
17 .\" <https://www.gnu.org/licenses/>.
18 .\"
19 .TH NANO 1 "version 8.7.1" "February 2026"
20
21 .SH NAME
22 nano \- Nano's ANOther text editor, inspired by Pico
23
24 .SH SYNOPSIS
25 .B nano
26 .RI [ options "] [[\fB+" line [\fB, column "]] " file ]...
27 .sp
28 .BR nano " [" \fIoptions "] [[" + [ crCR ]{ / | ? } \fIstring "] " \fIfile ]...
29
30 .SH NOTICE
31 Since version 8.0, to be newcomer friendly, \fB^F\fR starts a forward search,
32 \fB^B\fR starts a backward search, \fBM\-F\fR searches the next occurrence
33 forward, and \fBM\-B\fR searches the next occurrence backward. If you want
34 those keystrokes to do what they did before version 8.0, add the following
35 lines at the end of your \fInanorc\fR file:
36 .sp
37 .RS 4
38 .B bind ^F forward main
39 .br
40 .B bind ^B back main
41 .br
42 .B bind M\-F formatter main
43 .br
44 .B bind M\-B linter main
45 .RE
46 .sp
47
48 .SH DESCRIPTION
49 \fBnano\fR is a small and friendly text editor. It copies the look and feel
50 of Pico, but is free software, and implements several features that Pico
51 lacks, such as: opening multiple files, scrolling per line, undo/redo,
52 syntax coloring, line numbering, and soft-wrapping overlong lines.
53 .sp
54 When giving a filename on the command line, the cursor can be put on a
55 specific line by adding the line number with a plus sign (\fB+\fR) before
56 the filename, and even in a specific column by adding it with a comma.
57 Negative numbers count from the end of the file or line.
58 .sp
59 The cursor can be put on the first or last occurrence of a specific string
60 by specifying that string after \fB+/\fR or \fB+?\fR before the filename.
61 The string can be made case sensitive and/or caused to be interpreted as a
62 regular expression by inserting \fBc\fR and/or \fBr\fR after the \fB+\fR sign.
63 These search modes can be explicitly disabled by using the uppercase variant
64 of those letters: \fBC\fR and/or \fBR\fR. When the string contains spaces,
65 it needs to be enclosed in quotes. To give an example: to open a file at
66 the first occurrence of the word "Foo", you would do:
67 .sp
68 .RS 4
69 .BI "nano +c/Foo " file
70 .RE
71 .sp
72 As a special case: if instead of a filename a dash (\fB\-\fR) is given,
73 \fBnano\fR will read data from standard input.
74
75 .SH EDITING
76 Entering text and moving around in a file is straightforward: typing the
77 letters and using the normal cursor movement keys. Commands are entered
78 by using the Control (^) and the Alt or Meta (M\-) keys.
79 Typing \fB^K\fR deletes the current line and puts it in the cutbuffer.
80 Consecutive \fB^K\fRs put all deleted lines together in the cutbuffer.
81 Any cursor movement or executing any other command causes the next
82 \fB^K\fR to overwrite the cutbuffer. A \fB^U\fR pastes the current
83 contents of the cutbuffer at the current cursor position.
84 .sp
85 When a more precise piece of text needs to be cut or copied, you can mark
86 its start with \fB^6\fR, move the cursor to its end (the marked text is
87 highlighted), and then use \fB^K\fR to cut it, or \fBM\-6\fR to copy it to
88 the cutbuffer. You can also save the marked text to a file with \fB^O\fR,
89 or spell check it with \fB^T^T\fR.
90 .sp
91 On some terminals, text can be selected also by holding down Shift while
92 using the arrow keys. Holding down the Ctrl or Alt key too increases
93 the stride.
94 Any cursor movement without Shift being held cancels such a selection.
95 .sp
96 Any valid Unicode code point can be inserted into the buffer by typing
97 \fBM\-V\fR followed by the hexadecimal digits of the code point (concluded
98 with \fB<Space>\fR or \fB<Enter>\fR when it are fewer than six digits).
99 A literal control code (except \fB^J\fR) can be inserted by typing
100 \fBM\-V\fR followed by the pertinent keystroke.
101 .sp
102 The two lines at the bottom of the screen show some important commands;
103 the built-in help (\fB^G\fR) lists all the available ones.
104 The default key bindings can be changed via a \fInanorc\fR file \(em see
105 .BR nanorc (5).
106
107 .\" Never hyphenate these:
108 .hw ncurses terminfo
109
110 .SH OPTIONS
111 .TP
112 .BR \-A ", " \-\-smarthome
113 Make the Home key smarter. When Home is pressed anywhere but at the
114 very beginning of non-whitespace characters on a line, the cursor jumps
115 to that beginning (either forwards or backwards). If the cursor is
116 already at that position, it jumps to the true beginning of the line.
117 .TP
118 .BR \-B ", " \-\-backup
119 When saving a file, back up the previous version of it, using the current
120 filename suffixed with a tilde (\fB~\fR).
121 .TP
122 .BI \-C " directory\fR, " \-\-backupdir= directory
123 Make and keep not just one backup file, but make and keep a uniquely numbered
124 one every time a file is saved \(em when backups are enabled (\fB\-B\fR).
125 The uniquely numbered files are stored in the specified \fIdirectory\fR.
126 .TP
127 .BR \-D ", " \-\-boldtext
128 For the interface, use bold instead of reverse video.
129 This can be overridden for specific elements by setting the options
130 \fB\%titlecolor\fR, \fB\%statuscolor\fR, \fB\%promptcolor\fR,
131 \fB\%minicolor\fR, \fB\%keycolor\fR, \fB\%numbercolor\fR, and/or
132 \fB\%selectedcolor\fR in your nanorc file. See \fBnanorc\fR(5).
133 .TP
134 .BR \-E ", " \-\-tabstospaces
135 Convert each typed tab to spaces \(em to the number of spaces
136 that a tab at that position would take up.
137 (Note: pasted tabs are not converted.)
138 .TP
139 .BR \-F ", " \-\-multibuffer
140 Read a file into a new buffer by default.
141 .TP
142 .BR \-G ", " \-\-locking
143 Use vim-style file locking when editing files.
144 .TP
145 .BR \-H ", " \-\-historylog
146 Save the last hundred search strings and replacement strings and
147 executed commands, so they can be easily reused in later sessions.
148 .TP
149 .BR \-I ", " \-\-ignorercfiles
150 Don't look at the system's \fInanorc\fR nor at the user's \fInanorc\fR.
151 .TP
152 .BI \-J " number\fR, " \-\-guidestripe= number
153 Draw a vertical stripe at the given column, to help judge the width of the
154 text. (The color of the stripe can be changed with \fBset \%stripecolor\fR
155 in your \fInanorc\fR file.)
156 .TP
157 .BR \-K ", " \-\-rawsequences
158 Interpret escape sequences directly, instead of asking \fBncurses\fR
159 to translate them. (If you need this option to get some keys to work
160 properly, it means that the \fBterminfo\fR terminal description that
161 is used does not fully match the actual behavior of your terminal.
162 This can happen when you ssh into a BSD machine, for example.)
163 Using this option disables \fBnano\fR's mouse support.
164 .TP
165 .BR \-L ", " \-\-nonewlines
166 Don't automatically add a newline when a text does not end with one.
167 (This can cause you to save non-POSIX text files.)
168 .TP
169 .BR \-M ", " \-\-trimblanks
170 Snip trailing whitespace from the wrapped line when automatic
171 hard-wrapping occurs or when text is justified.
172 .TP
173 .BR \-N ", " \-\-noconvert
174 Disable automatic conversion of files from DOS/Mac format.
175 .TP
176 .BR \-O ", " \-\-bookstyle
177 When justifying, treat any line that starts with whitespace as the
178 beginning of a paragraph (unless auto-indenting is on).
179 .TP
180 .BR \-P ", " \-\-positionlog
181 For the 200 most recent files, log the last position of the cursor,
182 and place it at that position again upon reopening such a file.
183 Also save and restore the positions of any anchors.
184 .TP
185 .BI "\-Q """ regex\fB"\fR, " \-\-quotestr=""" regex """"
186 Set the regular expression for matching the quoting part of a line.
187 The default value is "\fB^([\ \\t]*([!#%:;>|}]|//))+\fR".
188 (Note that \fB\\t\fR stands for an actual Tab.)
189 This makes it possible to rejustify blocks of quoted text when composing
190 email, and to rewrap blocks of line comments when writing source code.
191 .TP
192 .BR \-R ", " \-\-restricted
193 Restricted mode: don't read or write to any file not specified on the
194 command line. This means: don't read or write history files;
195 don't allow suspending; don't allow spell checking;
196 don't allow a file to be appended to, prepended to, or saved under a
197 different name if it already has one; and don't make backup files.
198 Restricted mode can also be activated by invoking \fBnano\fR
199 with any name beginning with 'r' (e.g.\& "rnano").
200 .TP
201 .BR \-S ", " \-\-softwrap
202 Display over multiple screen rows lines that exceed the screen's width.
203 (You can make this soft-wrapping occur at whitespace instead of rudely at
204 the screen's edge, by using also \fB\-\-atblanks\fR.)
205 .TP
206 .BI \-T " number\fR, " \-\-tabsize= number
207 Set the size (width) of a tab to \fInumber\fR columns. The value of
208 \fInumber\fR must be greater than 0. The default value is \fB8\fR.
209 .TP
210 .BR \-U ", " \-\-quickblank
211 Make status-bar messages disappear after 1 keystroke instead of after 20.
212 Note that option \fB\-c\fR (\fB\-\-constantshow\fR) overrides this.
213 When option \fB\-\-minibar\fR or \fB\-\-zero\fR is in effect,
214 \fB\-\-quickblank\fR makes a message disappear after
215 0.8 seconds instead of after the default 1.5 seconds.
216 .
217 .TP
218 .BR \-V ", " \-\-version
219 Show the current version number and exit.
220 .TP
221 .BR \-W ", " \-\-wordbounds
222 Detect word boundaries differently by treating punctuation
223 characters as part of a word.
224 .TP
225 .BI "\-X """ characters\fB"\fR, " \-\-wordchars=""" characters """"
226 Specify which other characters (besides the normal alphanumeric ones)
227 should be considered as part of a word. When using this option, you
228 probably want to omit \fB\-W\fR (\fB\-\-wordbounds\fR).
229 .TP
230 .BI \-Y " name\fR, " \-\-syntax= name
231 Specify the name of the syntax highlighting to use from among the ones
232 defined in the \fInanorc\fR files.
233 .TP
234 .BR \-Z ", " \-\-zap
235 Let an unmodified Backspace or Delete erase the marked region
236 (instead of a single character, and without affecting the cutbuffer).
237 .TP
238 .BR \-a ", " \-\-atblanks
239 When doing soft line wrapping, wrap lines at whitespace
240 instead of always at the edge of the screen.
241 .TP
242 .BR \-b ", " \-\-breaklonglines
243 Automatically hard-wrap the current line when it becomes overlong,
244 that is: when it becomes wider than the value given with \fB\-r\fR
245 (\fB\-\-fill\fR). The default value for \fB-r\fR is the terminal's
246 width minus eight.
247 (This option is the opposite of \fB\-w\fR (\fB\-\-nowrap\fR) \(em
248 the last one given takes effect.)
249 .TP
250 .BR \-c ", " \-\-constantshow
251 Constantly report the cursor position on the status bar.
252 Note that this overrides option \fB\-U\fR (\fB\-\-quickblank\fR).
253 .TP
254 .BR \-d ", " \-\-rebinddelete
255 Interpret the Delete and Backspace keys differently so that both Backspace
256 and Delete work properly. You should only use this option when on your
257 system either Backspace acts like Delete or Delete acts like Backspace.
258 .TP
259 .BR \-e ", " \-\-emptyline
260 Do not use the line below the title bar, leaving it entirely blank.
261 .TP
262 .BI \-f " file\fR, " \-\-rcfile= file
263 Read only this \fIfile\fR for setting nano's options, instead of reading
264 both the system-wide and the user's nanorc files.
265 .TP
266 .BR \-g ", " \-\-showcursor
267 Make the cursor visible in the file browser (putting it on the
268 highlighted item) and in the help viewer. Useful for braille users
269 and people with poor vision.
270 .TP
271 .BR \-h ", " \-\-help
272 Show a summary of the available command-line options and exit.
273 .TP
274 .BR \-i ", " \-\-autoindent
275 Automatically indent a newly created line to the same number of tabs
276 and/or spaces as the previous line (or as the next line if the previous
277 line is the beginning of a paragraph).
278 .TP
279 .BR \-j ", " \-\-jumpyscrolling
280 Scroll the buffer contents per half-screen instead of per line.
281 .TP
282 .BR \-k ", " \-\-cutfromcursor
283 Make the 'Cut Text' command (normally \fB^K\fR) cut from the current cursor
284 position to the end of the line, instead of cutting the entire line.
285 .TP
286 .BR \-l ", " \-\-linenumbers
287 Display line numbers to the left of the text area.
288 (Any line with an anchor additionally gets a mark in the margin.)
289 .TP
290 .BR \-m ", " \-\-mouse
291 Enable mouse support, if available for your system. When enabled, mouse
292 clicks can be used to place the cursor, set the mark (with a double
293 click), and execute shortcuts. The mouse works in the X Window
294 System, and on the console when gpm is running. Text can still be
295 selected through dragging by holding down the Shift key.
296 .TP
297 .BR \-n ", " \-\-noread
298 Treat any name given on the command line as a new file. This allows
299 \fBnano\fR to write to named pipes: it starts with a blank buffer,
300 and writes to the pipe when the user saves the "file". This way
301 \fBnano\fR can be used as an editor in combination with for instance
302 \fBgpg\fR without having to write sensitive data to disk first.
303 .TP
304 .BI \-o " directory\fR, " \-\-operatingdir= directory
305 Change to the given \fIdirectory\fR, and allow reading and writing
306 files only in this directory and its subdirectories.
307 .TP
308 .BR \-p ", " \-\-preserve
309 Preserve the XOFF and XON sequences (\fB^S\fR and \fB^Q\fR) so that
310 they are caught by the terminal (stopping and resuming the output).
311 Note that option \fB\-/\fR (\fB\-\-modernbindings\fR) overrides this.
312 .TP
313 .BR \-q ", " \-\-indicator
314 Display a "scrollbar" on the righthand side of the edit window.
315 It shows the position of the viewport in the buffer
316 and how much of the buffer is covered by the viewport.
317 .TP
318 .BI \-r " number\fR, " \-\-fill= number
319 Set the target width for justifying and automatic hard-wrapping at this
320 \fInumber\fR of columns. If the value is 0 or less, wrapping occurs
321 at the width of the screen minus \fInumber\fR columns, allowing the wrap
322 point to vary along with the width of the screen if the screen is resized.
323 The default value is \fB\-8\fR.
324 .TP
325 .B "\-s ""\fIprogram\fR [\fIargument \fR...]\fB""\fR, \fB\-\-speller=""\fIprogram\fR [\fIargument \fR...]\fB"""
326 Use this command to perform spell checking and correcting, instead of
327 using the built-in corrector that calls \fBhunspell\fR(1) or \fBspell\fR(1).
328 .TP
329 .BR \-t ", " \-\-saveonexit
330 Save a changed buffer without prompting (when exiting with \fB^X\fR).
331 .TP
332 .BR \-u ", " \-\-unix
333 Save a file by default in Unix format. This overrides nano's
334 default behavior of saving a file in the format that it had.
335 (This option has no effect when you also use \fB\-\-noconvert\fR.)
336 .TP
337 .BR \-v ", " \-\-view
338 Just view the file and disallow editing: read-only mode.
339 This mode allows the user to open also other files for viewing,
340 unless \fB\-\-restricted\fR is given too.
341 .TP
342 .BR \-w ", " \-\-nowrap
343 Do not automatically hard-wrap the current line when it becomes overlong.
344 This is the default. (This option is the opposite of \fB\-b\fR
345 (\fB\-\-breaklonglines\fR) \(em the last one given takes effect.)
346 .TP
347 .BR \-x ", " \-\-nohelp
348 Don't show the two help lines at the bottom of the screen.
349 .TP
350 .BR \-y ", " \-\-afterends
351 Make Ctrl+Right and Ctrl+Delete stop at word ends instead of beginnings.
352 .TP
353 .BR \-z ", " \-\-listsyntaxes
354 List the names of the available syntaxes and exit.
355 .TP
356 .BR \-! ", " \-\-magic
357 When neither the file's name nor its first line give a clue,
358 try using libmagic to determine the applicable syntax.
359 .TP
360 .BR \-@ ", " \-\-colonparsing
361 When a filename given on the command line ends in a colon plus digits
362 and this filename does not exist, then snip the colon plus digits and
363 understand the digits as a line number. If the trimmed filename does
364 not exist either, then repeat the process and understand the obtained
365 two numbers as line and column number. But if the doubly trimmed
366 filename does not exist either, then forget the trimming and accept
367 the original filename as is. To disable this colon parsing for some
368 file, use \fB+1\fR or similar before the relevant filename.
369 .TP
370 .BR \-% ", " \-\-stateflags
371 Use the top-right corner of the screen for showing some state flags:
372 \fBI\fR when auto-indenting, \fBM\fR when the mark is on, \fBL\fR when
373 hard-wrapping (breaking long lines), \fBR\fR when recording a macro,
374 and \fBS\fR when soft-wrapping.
375 When the buffer is modified, a star (\fB*\fR) is shown after the
376 filename in the center of the title bar.
377 .TP
378 .BR \-_ ", " \-\-minibar
379 Suppress the title bar and instead show information about
380 the current buffer at the bottom of the screen, in the space
381 for the status bar. In this "mini bar" the filename is shown
382 on the left, followed by an asterisk if the buffer has been modified.
383 On the right are displayed the current line and column number, the
384 code of the character under the cursor (in Unicode format: U+xxxx),
385 the same flags as are shown by \fB\-\-stateflags\fR, and a percentage
386 that expresses how far the cursor is into the file (linewise).
387 When a file is loaded or saved, and also when switching between buffers,
388 the number of lines in the buffer is displayed after the filename.
389 This number is cleared upon the next keystroke, or replaced with an
390 [i/n] counter when multiple buffers are open.
391 The line plus column numbers and the character code are displayed only when
392 \fB\-\-constantshow\fR is used, and can be toggled on and off with \fBM\-C\fR.
393 The state flags are displayed only when \fB\-\-stateflags\fR is used.
394 .TP
395 .BR \-0 ", " \-\-zero
396 Hide all elements of the interface (title bar, status bar, and help lines)
397 and use all rows of the terminal for showing the contents of the buffer.
398 The status bar appears only when there is a significant message,
399 and disappears after 1.5 seconds or upon the next keystroke.
400 With \fBM\-Z\fR the title bar plus status bar can be toggled.
401 With \fBM\-X\fR the help lines.
402 .TP
403 .BR \-/ ", " \-\-modernbindings
404 Use key bindings similar to the ones that most modern programs use:
405 \fB^X\fR cuts, \fB^C\fR copies, \fB^V\fR pastes,
406 \fB^Z\fR undoes, \fB^Y\fR redoes,
407 \fB^F\fR searches forward, \fB^G\fR searches next,
408 \fB^S\fR saves, \fB^O\fR opens a file, \fB^Q\fR quits,
409 and (when the terminal permits) \fB^H\fR shows help.
410 Furthermore, \fB^A\fR sets the mark,
411 \fB^R\fR makes replacements, \fB^D\fR searches previous,
412 \fB^P\fR shows the position, \fB^T\fR goes to a line,
413 \fB^W\fR writes out a file, and \fB^E\fR executes a command.
414 Note that this overrides option \fB\-p\fR (\fB\-\-preserve\fR).
415
416 .SH TOGGLES
417 Several of the above options can be switched on and off also while
418 \fBnano\fR is running. For example, \fBM\-L\fR toggles the
419 hard-wrapping of long lines, \fBM\-S\fR toggles soft-wrapping,
420 \fBM\-N\fR toggles line numbers, \fBM\-M\fR toggles the mouse,
421 \fBM\-I\fR auto-indentation, and \fBM\-X\fR the help lines.
422 See at the end of the \fB^G\fR help text for a complete list.
423 .sp
424 The \fBM\-X\fR toggle is special: it works in all menus except
425 the help viewer and the linter. All other toggles work in
426 the main menu only.
427
428 .SH FILES
429 When \fB\-\-rcfile\fR is given, \fBnano\fR reads just the specified file
430 for setting its options and syntaxes and key bindings. Without that
431 option, \fBnano\fR reads two configuration files: first the system's
432 \fInanorc\fR (if it exists), and then the user's \fInanorc\fR (if it
433 exists), either \fI~/.nanorc\fR or \fI$XDG_CONFIG_HOME/nano/nanorc\fR
434 or \fI~/.config/nano/nanorc\fR, whichever is encountered first. See
435 .BR nanorc (5)
436 for more information on the possible contents of those files.
437 .sp
438 See \fI/usr/share/nano/\fR and \fI/usr/share/nano/extra/\fR
439 for available syntax-coloring definitions.
440
441 .SH EXIT STATUS
442 .TP
443 .B 0
444 The editor finished normally.
445 .TP
446 .B 1
447 An invalid option or option argument was given.
448 .TP
449 .B 2
450 The last open buffer was discarded (with \fB^O^Q\fR or \fB^X^Q\fR).
451
452 .SH NOTES
453 Suspension is enabled by default, reachable via \fB^T^Z\fR.
454 (If you want a plain \fB^Z\fR to suspend nano, add
455 \fBbind ^Z suspend main\fR to your nanorc.)
456 .sp
457 At a Yes-No prompt, \fB^Y\fR can be used for "Yes", \fB^N\fR for "No",
458 and \fB^A\fR for "All".
459 (And when exiting, \fB^Q\fR can be used for "Quit with error".)
460 These unlisted bindings work in any locale.
461 .sp
462 When you want to copy marked text from \fBnano\fR to the system's clipboard,
463 see one of the examples in the \fBnanorc\fR(5) man page.
464 .sp
465 If no alternative spell checker command is specified on the command
466 line nor in one of the \fInanorc\fR files, \fBnano\fR checks the
467 \fBSPELL\fR environment variable for one.
468 .sp
469 In some cases \fBnano\fR tries to dump the buffer into an emergency file.
470 This happens mainly if \fBnano\fR receives a SIGHUP or SIGTERM or runs out
471 of memory. It writes the buffer into a file named \fInano.save\fR if the
472 buffer didn't have a name already, or adds a ".save" suffix to the current
473 filename. If an emergency file with that name already exists in the
474 current directory, it adds ".save" plus a number (e.g.\& ".save.1") to
475 the current filename in order to make it unique. In multibuffer mode,
476 \fBnano\fR writes all open buffers to their respective emergency files.
477 .sp
478 If you have any question about how to use \fBnano\fR in some specific
479 situation, you can ask on \fIhelp\[email protected]\fR.
480
481 .SH BUGS
482 The recording and playback of keyboard macros works correctly only on a
483 terminal emulator, not on a Linux console (VT), because the latter does
484 not by default distinguish modified from unmodified arrow keys.
485 .sp
486 Please report any other bugs that you encounter via:
487 .br
488 .IR https://savannah.gnu.org/bugs/?group=nano .
489 .sp
490 When nano crashes, it saves any modified buffers to emergency .save files.
491 If you are able to reproduce the crash and you want to get a backtrace, define
492 the environment variable \fBNANO_NOCATCH\fR.
493
494 .SH HOMEPAGE
495 .I https://nano\-editor.org/
496
497 .SH SEE ALSO
498 .BR nanorc (5)
499 .sp
500 \fI/usr/share/doc/nano/\fR (or equivalent on your system)