Debian Codegraph @

upstream/debian-trixie/man1/nano.1

raw
1 .\" Copyright (C) 1999-2011, 2013-2025 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.4" "April 2025"
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 .TP
184 .BI "\-Q """ regex\fB"\fR, " \-\-quotestr=""" regex """"
185 Set the regular expression for matching the quoting part of a line.
186 The default value is "\fB^([\ \\t]*([!#%:;>|}]|//))+\fR".
187 (Note that \fB\\t\fR stands for an actual Tab.)
188 This makes it possible to rejustify blocks of quoted text when composing
189 email, and to rewrap blocks of line comments when writing source code.
190 .TP
191 .BR \-R ", " \-\-restricted
192 Restricted mode: don't read or write to any file not specified on the
193 command line. This means: don't read or write history files;
194 don't allow suspending; don't allow spell checking;
195 don't allow a file to be appended to, prepended to, or saved under a
196 different name if it already has one; and don't make backup files.
197 Restricted mode can also be activated by invoking \fBnano\fR
198 with any name beginning with 'r' (e.g.\& "rnano").
199 .TP
200 .BR \-S ", " \-\-softwrap
201 Display over multiple screen rows lines that exceed the screen's width.
202 (You can make this soft-wrapping occur at whitespace instead of rudely at
203 the screen's edge, by using also \fB\-\-atblanks\fR.)
204 .TP
205 .BI \-T " number\fR, " \-\-tabsize= number
206 Set the size (width) of a tab to \fInumber\fR columns. The value of
207 \fInumber\fR must be greater than 0. The default value is \fB8\fR.
208 .TP
209 .BR \-U ", " \-\-quickblank
210 Make status-bar messages disappear after 1 keystroke instead of after 20.
211 Note that option \fB\-c\fR (\fB\-\-constantshow\fR) overrides this.
212 When option \fB\-\-minibar\fR or \fB\-\-zero\fR is in effect,
213 \fB\-\-quickblank\fR makes a message disappear after
214 0.8 seconds instead of after the default 1.5 seconds.
215 .
216 .TP
217 .BR \-V ", " \-\-version
218 Show the current version number and exit.
219 .TP
220 .BR \-W ", " \-\-wordbounds
221 Detect word boundaries differently by treating punctuation
222 characters as part of a word.
223 .TP
224 .BI "\-X """ characters\fB"\fR, " \-\-wordchars=""" characters """"
225 Specify which other characters (besides the normal alphanumeric ones)
226 should be considered as part of a word. When using this option, you
227 probably want to omit \fB\-W\fR (\fB\-\-wordbounds\fR).
228 .TP
229 .BI \-Y " name\fR, " \-\-syntax= name
230 Specify the name of the syntax highlighting to use from among the ones
231 defined in the \fInanorc\fR files.
232 .TP
233 .BR \-Z ", " \-\-zap
234 Let an unmodified Backspace or Delete erase the marked region
235 (instead of a single character, and without affecting the cutbuffer).
236 .TP
237 .BR \-a ", " \-\-atblanks
238 When doing soft line wrapping, wrap lines at whitespace
239 instead of always at the edge of the screen.
240 .TP
241 .BR \-b ", " \-\-breaklonglines
242 Automatically hard-wrap the current line when it becomes overlong.
243 (This option is the opposite of \fB\-w\fR (\fB\-\-nowrap\fR) --
244 the last one given takes effect.)
245 .TP
246 .BR \-c ", " \-\-constantshow
247 Constantly report the cursor position on the status bar.
248 Note that this overrides option \fB\-U\fR (\fB\-\-quickblank\fR).
249 .TP
250 .BR \-d ", " \-\-rebinddelete
251 Interpret the Delete and Backspace keys differently so that both Backspace
252 and Delete work properly. You should only use this option when on your
253 system either Backspace acts like Delete or Delete acts like Backspace.
254 .TP
255 .BR \-e ", " \-\-emptyline
256 Do not use the line below the title bar, leaving it entirely blank.
257 .TP
258 .BI \-f " file\fR, " \-\-rcfile= file
259 Read only this \fIfile\fR for setting nano's options, instead of reading
260 both the system-wide and the user's nanorc files.
261 .TP
262 .BR \-g ", " \-\-showcursor
263 Make the cursor visible in the file browser (putting it on the
264 highlighted item) and in the help viewer. Useful for braille users
265 and people with poor vision.
266 .TP
267 .BR \-h ", " \-\-help
268 Show a summary of the available command-line options and exit.
269 .TP
270 .BR \-i ", " \-\-autoindent
271 Automatically indent a newly created line to the same number of tabs
272 and/or spaces as the previous line (or as the next line if the previous
273 line is the beginning of a paragraph).
274 .TP
275 .BR \-j ", " \-\-jumpyscrolling
276 Scroll the buffer contents per half-screen instead of per line.
277 .TP
278 .BR \-k ", " \-\-cutfromcursor
279 Make the 'Cut Text' command (normally \fB^K\fR) cut from the current cursor
280 position to the end of the line, instead of cutting the entire line.
281 .TP
282 .BR \-l ", " \-\-linenumbers
283 Display line numbers to the left of the text area.
284 (Any line with an anchor additionally gets a mark in the margin.)
285 .TP
286 .BR \-m ", " \-\-mouse
287 Enable mouse support, if available for your system. When enabled, mouse
288 clicks can be used to place the cursor, set the mark (with a double
289 click), and execute shortcuts. The mouse works in the X Window
290 System, and on the console when gpm is running. Text can still be
291 selected through dragging by holding down the Shift key.
292 .TP
293 .BR \-n ", " \-\-noread
294 Treat any name given on the command line as a new file. This allows
295 \fBnano\fR to write to named pipes: it starts with a blank buffer,
296 and writes to the pipe when the user saves the "file". This way
297 \fBnano\fR can be used as an editor in combination with for instance
298 \fBgpg\fR without having to write sensitive data to disk first.
299 .TP
300 .BI \-o " directory\fR, " \-\-operatingdir= directory
301 Set the operating directory. This makes \fBnano\fR set up something
302 similar to a chroot.
303 .TP
304 .BR \-p ", " \-\-preserve
305 Preserve the XOFF and XON sequences (\fB^S\fR and \fB^Q\fR) so that
306 they are caught by the terminal (stopping and resuming the output).
307 Note that option \fB\-/\fR (\fB\-\-modernbindings\fR) overrides this.
308 .TP
309 .BR \-q ", " \-\-indicator
310 Display a "scrollbar" on the righthand side of the edit window.
311 It shows the position of the viewport in the buffer
312 and how much of the buffer is covered by the viewport.
313 .TP
314 .BI \-r " number\fR, " \-\-fill= number
315 Set the target width for justifying and automatic hard-wrapping at this
316 \fInumber\fR of columns. If the value is 0 or less, wrapping occurs
317 at the width of the screen minus \fInumber\fR columns, allowing the wrap
318 point to vary along with the width of the screen if the screen is resized.
319 The default value is \fB\-8\fR.
320 .TP
321 .B "\-s ""\fIprogram\fR [\fIargument \fR...]\fB""\fR, \fB\-\-speller=""\fIprogram\fR [\fIargument \fR...]\fB"""
322 Use this command to perform spell checking and correcting, instead of
323 using the built-in corrector that calls \fBhunspell\fR(1) or \fBspell\fR(1).
324 .TP
325 .BR \-t ", " \-\-saveonexit
326 Save a changed buffer without prompting (when exiting with \fB^X\fR).
327 .TP
328 .BR \-u ", " \-\-unix
329 Save a file by default in Unix format. This overrides nano's
330 default behavior of saving a file in the format that it had.
331 (This option has no effect when you also use \fB\-\-noconvert\fR.)
332 .TP
333 .BR \-v ", " \-\-view
334 Just view the file and disallow editing: read-only mode.
335 This mode allows the user to open also other files for viewing,
336 unless \fB\-\-restricted\fR is given too.
337 .TP
338 .BR \-w ", " \-\-nowrap
339 Do not automatically hard-wrap the current line when it becomes overlong.
340 This is the default. (This option is the opposite of \fB\-b\fR
341 (\fB\-\-breaklonglines\fR) \(em the last one given takes effect.)
342 .TP
343 .BR \-x ", " \-\-nohelp
344 Don't show the two help lines at the bottom of the screen.
345 .TP
346 .BR \-y ", " \-\-afterends
347 Make Ctrl+Right and Ctrl+Delete stop at word ends instead of beginnings.
348 .TP
349 .BR \-z ", " \-\-listsyntaxes
350 List the names of the available syntaxes and exit.
351 .TP
352 .BR \-! ", " \-\-magic
353 When neither the file's name nor its first line give a clue,
354 try using libmagic to determine the applicable syntax.
355 .TP
356 .BR \-@ ", " \-\-colonparsing
357 When a filename given on the command line ends in a colon plus digits
358 and this filename does not exist, then snip the colon plus digits and
359 understand the digits as a line number. If the trimmed filename does
360 not exist either, then repeat the process and understand the obtained
361 two numbers as line and column number. But if the doubly trimmed
362 filename does not exist either, then forget the trimming and accept
363 the original filename as is. To disable this colon parsing for some
364 file, use \fB+1\fR or similar before the relevant filename.
365 .TP
366 .BR \-% ", " \-\-stateflags
367 Use the top-right corner of the screen for showing some state flags:
368 \fBI\fR when auto-indenting, \fBM\fR when the mark is on, \fBL\fR when
369 hard-wrapping (breaking long lines), \fBR\fR when recording a macro,
370 and \fBS\fR when soft-wrapping.
371 When the buffer is modified, a star (\fB*\fR) is shown after the
372 filename in the center of the title bar.
373 .TP
374 .BR \-_ ", " \-\-minibar
375 Suppress the title bar and instead show information about
376 the current buffer at the bottom of the screen, in the space
377 for the status bar. In this "mini bar" the filename is shown
378 on the left, followed by an asterisk if the buffer has been modified.
379 On the right are displayed the current line and column number, the
380 code of the character under the cursor (in Unicode format: U+xxxx),
381 the same flags as are shown by \fB\-\-stateflags\fR, and a percentage
382 that expresses how far the cursor is into the file (linewise).
383 When a file is loaded or saved, and also when switching between buffers,
384 the number of lines in the buffer is displayed after the filename.
385 This number is cleared upon the next keystroke, or replaced with an
386 [i/n] counter when multiple buffers are open.
387 The line plus column numbers and the character code are displayed only when
388 \fB\-\-constantshow\fR is used, and can be toggled on and off with \fBM\-C\fR.
389 The state flags are displayed only when \fB\-\-stateflags\fR is used.
390 .TP
391 .BR \-0 ", " \-\-zero
392 Hide all elements of the interface (title bar, status bar, and help lines)
393 and use all rows of the terminal for showing the contents of the buffer.
394 The status bar appears only when there is a significant message,
395 and disappears after 1.5 seconds or upon the next keystroke.
396 With \fBM\-Z\fR the title bar plus status bar can be toggled.
397 With \fBM\-X\fR the help lines.
398 .TP
399 .BR \-/ ", " \-\-modernbindings
400 Use key bindings similar to the ones that most modern programs use:
401 \fB^X\fR cuts, \fB^C\fR copies, \fB^V\fR pastes,
402 \fB^Z\fR undoes, \fB^Y\fR redoes,
403 \fB^F\fR searches forward, \fB^G\fR searches next,
404 \fB^S\fR saves, \fB^O\fR opens a file, \fB^Q\fR quits,
405 and (when the terminal permits) \fB^H\fR shows help.
406 Furthermore, \fB^A\fR sets the mark,
407 \fB^R\fR makes replacements, \fB^D\fR searches previous,
408 \fB^P\fR shows the position, \fB^T\fR goes to a line,
409 \fB^W\fR writes out a file, and \fB^E\fR executes a command.
410 Note that this overrides option \fB\-p\fR (\fB\-\-preserve\fR).
411
412 .SH TOGGLES
413 Several of the above options can be switched on and off also while
414 \fBnano\fR is running. For example, \fBM\-L\fR toggles the
415 hard-wrapping of long lines, \fBM\-S\fR toggles soft-wrapping,
416 \fBM\-N\fR toggles line numbers, \fBM\-M\fR toggles the mouse,
417 \fBM\-I\fR auto-indentation, and \fBM\-X\fR the help lines.
418 See at the end of the \fB^G\fR help text for a complete list.
419 .sp
420 The \fBM\-X\fR toggle is special: it works in all menus except
421 the help viewer and the linter. All other toggles work in
422 the main menu only.
423
424 .SH FILES
425 When \fB\-\-rcfile\fR is given, \fBnano\fR reads just the specified file
426 for setting its options and syntaxes and key bindings. Without that
427 option, \fBnano\fR reads two configuration files: first the system's
428 \fInanorc\fR (if it exists), and then the user's \fInanorc\fR (if it
429 exists), either \fI~/.nanorc\fR or \fI$XDG_CONFIG_HOME/nano/nanorc\fR
430 or \fI~/.config/nano/nanorc\fR, whichever is encountered first. See
431 .BR nanorc (5)
432 for more information on the possible contents of those files.
433 .sp
434 See \fI/usr/share/nano/\fR and \fI/usr/share/nano/extra/\fR
435 for available syntax-coloring definitions.
436
437 .SH NOTES
438 Suspension is enabled by default, reachable via \fB^T^Z\fR.
439 (If you want a plain \fB^Z\fR to suspend nano, add
440 \fBbind ^Z suspend main\fR to your nanorc.)
441 .sp
442 At a Yes-No prompt, \fB^Y\fR can be used for "Yes", \fB^N\fR for "No",
443 and \fB^A\fR for "All". These unlisted bindings work in any locale.
444 .sp
445 When you want to copy marked text from \fBnano\fR to the system's clipboard,
446 see one of the examples in the \fBnanorc\fR(5) man page.
447 .sp
448 If no alternative spell checker command is specified on the command
449 line nor in one of the \fInanorc\fR files, \fBnano\fR checks the
450 \fBSPELL\fR environment variable for one.
451 .sp
452 In some cases \fBnano\fR tries to dump the buffer into an emergency file.
453 This happens mainly if \fBnano\fR receives a SIGHUP or SIGTERM or runs out
454 of memory. It writes the buffer into a file named \fInano.save\fR if the
455 buffer didn't have a name already, or adds a ".save" suffix to the current
456 filename. If an emergency file with that name already exists in the
457 current directory, it adds ".save" plus a number (e.g.\& ".save.1") to
458 the current filename in order to make it unique. In multibuffer mode,
459 \fBnano\fR writes all open buffers to their respective emergency files.
460 .sp
461 If you have any question about how to use \fBnano\fR in some specific
462 situation, you can ask on \fIhelp\[email protected]\fR.
463
464 .SH BUGS
465 The recording and playback of keyboard macros works correctly only on a
466 terminal emulator, not on a Linux console (VT), because the latter does
467 not by default distinguish modified from unmodified arrow keys.
468 .sp
469 Please report any other bugs that you encounter via:
470 .br
471 .IR https://savannah.gnu.org/bugs/?group=nano .
472 .sp
473 When nano crashes, it saves any modified buffers to emergency .save files.
474 If you are able to reproduce the crash and you want to get a backtrace, define
475 the environment variable \fBNANO_NOCATCH\fR.
476
477 .SH HOMEPAGE
478 .I https://nano\-editor.org/
479
480 .SH SEE ALSO
481 .BR nanorc (5)
482 .sp
483 \fI/usr/share/doc/nano/\fR (or equivalent on your system)