1NANO(1) General Commands Manual NANO(1)
2
3
4
6 nano - Nano's ANOther editor, inspired by Pico
7
8
10 nano [options] [[+line[,column]] file]...
11
12 nano [options] [[+[crCR](/|?)string] file]...
13
14
16 nano is a small and friendly editor. It copies the look and feel of
17 Pico, but is free software, and implements several features that Pico
18 lacks, such as: opening multiple files, scrolling per line, undo/redo,
19 syntax coloring, line numbering, and soft-wrapping overlong lines.
20
21 When giving a filename on the command line, the cursor can be put on a
22 specific line by adding the line number with a plus sign (+) before the
23 filename, and even in a specific column by adding it with a comma.
24 (Negative numbers count from the end of the file or line.) The cursor
25 can be put on the first or last occurrence of a specific string by
26 specifying that string after +/ or +? before the filename. The string
27 can be made case sensitive and/or caused to be interpreted as a regular
28 expression by inserting c and/or r after the + sign. These search
29 modes can be explicitly disabled by using the uppercase variant of
30 those letters: C and/or R. When the string contains spaces, it needs
31 to be enclosed in quotes. To give an example: to open a file at the
32 first occurrence of the word "Foo", you would do:
33
34 nano +c/Foo file
35
36 As a special case: if instead of a filename a dash (-) is given, nano
37 will read data from standard input.
38
39
41 Entering text and moving around in a file is straightforward: typing
42 the letters and using the normal cursor movement keys. Commands are
43 entered by using the Control (^) and the Alt or Meta (M-) keys. Typing
44 ^K deletes the current line and puts it in the cutbuffer. Consecutive
45 ^Ks will put all deleted lines together in the cutbuffer. Any cursor
46 movement or executing any other command will cause the next ^K to over‐
47 write the cutbuffer. A ^U will paste the current contents of the cut‐
48 buffer at the current cursor position.
49
50 When a more precise piece of text needs to be cut or copied, you can
51 mark its start with ^6, move the cursor to its end (the marked text
52 will be highlighted), and then use ^K to cut it, or M-6 to copy it to
53 the cutbuffer. You can also save the marked text to a file with ^O, or
54 spell check it with ^T^T.
55
56 On some terminals, text can be selected also by holding down Shift
57 while using the arrow keys. Holding down the Ctrl or Alt key too will
58 increase the stride. Any cursor movement without Shift being held will
59 cancel such a selection.
60
61 The two lines at the bottom of the screen show some important commands;
62 the built-in help (^G) lists all the available ones. The default key
63 bindings can be changed via a nanorc file -- see nanorc(5).
64
65
67 Since version 4.0, nano by default:
68
69 • does not automatically hard-wrap lines that become overlong,
70 • includes the line below the title bar in the editing area,
71 • does linewise (smooth) scrolling.
72
73 If you want the old, Pico behavior back, you can use --breaklonglines,
74 --emptyline, and --jumpyscrolling (or -bej for short).
75
76
78 -A, --smarthome
79 Make the Home key smarter. When Home is pressed anywhere but at
80 the very beginning of non-whitespace characters on a line, the
81 cursor will jump to that beginning (either forwards or back‐
82 wards). If the cursor is already at that position, it will jump
83 to the true beginning of the line.
84
85 -B, --backup
86 When saving a file, back up the previous version of it, using
87 the current filename suffixed with a tilde (~).
88
89 -C directory, --backupdir=directory
90 Make and keep not just one backup file, but make and keep a
91 uniquely numbered one every time a file is saved -- when backups
92 are enabled (-B). The uniquely numbered files are stored in the
93 specified directory.
94
95 -D, --boldtext
96 For the interface, use bold instead of reverse video. This will
97 be overridden by setting the options titlecolor, statuscolor,
98 keycolor, functioncolor, numbercolor, and/or selectedcolor in
99 your nanorc file. See nanorc(5).
100
101 -E, --tabstospaces
102 Convert each typed tab to spaces -- to the number of spaces that
103 a tab at that position would take up.
104
105 -F, --multibuffer
106 Read a file into a new buffer by default.
107
108 -G, --locking
109 Use vim-style file locking when editing files.
110
111 -H, --historylog
112 Save the last hundred search strings and replacement strings and
113 executed commands, so they can be easily reused in later ses‐
114 sions.
115
116 -I, --ignorercfiles
117 Don't look at the system's nanorc nor at the user's nanorc.
118
119 -J number, --guidestripe=number
120 Draw a vertical stripe at the given column, to help judge the
121 width of the text. (The color of the stripe can be changed with
122 set stripecolor in your nanorc file.)
123
124 -K, --rawsequences
125 Interpret escape sequences directly, instead of asking ncurses
126 to translate them. (If you need this option to get some keys to
127 work properly, it means that the terminfo terminal description
128 that is used does not fully match the actual behavior of your
129 terminal. This can happen when you ssh into a BSD machine, for
130 example.) Using this option disables nano's mouse support.
131
132 -L, --nonewlines
133 Don't automatically add a newline when a text does not end with
134 one. (This can cause you to save non-POSIX text files.)
135
136 -M, --trimblanks
137 Snip trailing whitespace from the wrapped line when automatic
138 hard-wrapping occurs or when text is justified.
139
140 -N, --noconvert
141 Disable automatic conversion of files from DOS/Mac format.
142
143 -O, --bookstyle
144 When justifying, treat any line that starts with whitespace as
145 the beginning of a paragraph (unless auto-indenting is on).
146
147 -P, --positionlog
148 For the 200 most recent files, log the last position of the cur‐
149 sor, and place it at that position again upon reopening such a
150 file.
151
152 -Q "regex", --quotestr="regex"
153 Set the regular expression for matching the quoting part of a
154 line. The default value is "^([ \t]*([!#%:;>|}]|//))+". (Note
155 that \t stands for an actual Tab.) This makes it possible to
156 rejustify blocks of quoted text when composing email, and to re‐
157 wrap blocks of line comments when writing source code.
158
159 -R, --restricted
160 Restricted mode: don't read or write to any file not specified
161 on the command line. This means: don't read or write history
162 files; don't allow suspending; don't allow spell checking; don't
163 allow a file to be appended to, prepended to, or saved under a
164 different name if it already has one; and don't make backup
165 files. Restricted mode can also be activated by invoking nano
166 with any name beginning with 'r' (e.g. "rnano").
167
168 -S, --softwrap
169 Display over multiple screen rows lines that exceed the screen's
170 width. (You can make this soft-wrapping occur at whitespace in‐
171 stead of rudely at the screen's edge, by using also --atblanks.)
172 (The old short option, -$, is deprecated.)
173
174 -T number, --tabsize=number
175 Set the size (width) of a tab to number columns. The value of
176 number must be greater than 0. The default value is 8.
177
178 -U, --quickblank
179 Make status-bar messages disappear after 1 keystroke instead of
180 after 20. Note that option -c (--constantshow) overrides this.
181 When option --minibar or --zero is in effect, --quickblank makes
182 a message disappear after 0.8 seconds instead of after the de‐
183 fault 1.5 seconds.
184
185 -V, --version
186 Show the current version number and exit.
187
188 -W, --wordbounds
189 Detect word boundaries differently by treating punctuation char‐
190 acters as part of a word.
191
192 -X "characters", --wordchars="characters"
193 Specify which other characters (besides the normal alphanumeric
194 ones) should be considered as part of a word. When using this
195 option, you probably want to omit -W (--wordbounds).
196
197 -Y name, --syntax=name
198 Specify the name of the syntax highlighting to use from among
199 the ones defined in the nanorc files.
200
201 -Z, --zap
202 Let an unmodified Backspace or Delete erase the marked region
203 (instead of a single character, and without affecting the cut‐
204 buffer).
205
206 -a, --atblanks
207 When doing soft line wrapping, wrap lines at whitespace instead
208 of always at the edge of the screen.
209
210 -b, --breaklonglines
211 Automatically hard-wrap the current line when it becomes over‐
212 long. (This option is the opposite of -w (--nowrap) -- the last
213 one given takes effect.)
214
215 -c, --constantshow
216 Constantly show the cursor position on the status bar. Note
217 that this overrides option -U (--quickblank).
218
219 -d, --rebinddelete
220 Interpret the Delete and Backspace keys differently so that both
221 Backspace and Delete work properly. You should only use this
222 option when on your system either Backspace acts like Delete or
223 Delete acts like Backspace.
224
225 -e, --emptyline
226 Do not use the line below the title bar, leaving it entirely
227 blank.
228
229 -f file, --rcfile=file
230 Read only this file for setting nano's options, instead of read‐
231 ing both the system-wide and the user's nanorc files.
232
233 -g, --showcursor
234 Make the cursor visible in the file browser (putting it on the
235 highlighted item) and in the help viewer. Useful for braille
236 users and people with poor vision.
237
238 -h, --help
239 Show a summary of the available command-line options and exit.
240
241 -i, --autoindent
242 Automatically indent a newly created line to the same number of
243 tabs and/or spaces as the previous line (or as the next line if
244 the previous line is the beginning of a paragraph).
245
246 -j, --jumpyscrolling
247 Scroll the buffer contents per half-screen instead of per line.
248
249 -k, --cutfromcursor
250 Make the 'Cut Text' command (normally ^K) cut from the current
251 cursor position to the end of the line, instead of cutting the
252 entire line.
253
254 -l, --linenumbers
255 Display line numbers to the left of the text area. (Any line
256 with an anchor additionally gets a mark in the margin.)
257
258 -m, --mouse
259 Enable mouse support, if available for your system. When en‐
260 abled, mouse clicks can be used to place the cursor, set the
261 mark (with a double click), and execute shortcuts. The mouse
262 will work in the X Window System, and on the console when gpm is
263 running. Text can still be selected through dragging by holding
264 down the Shift key.
265
266 -n, --noread
267 Treat any name given on the command line as a new file. This
268 allows nano to write to named pipes: it will start with a blank
269 buffer, and will write to the pipe when the user saves the
270 "file". This way nano can be used as an editor in combination
271 with for instance gpg without having to write sensitive data to
272 disk first.
273
274 -o directory, --operatingdir=directory
275 Set the operating directory. This makes nano set up something
276 similar to a chroot.
277
278 -p, --preserve
279 Preserve the XON and XOFF sequences (^Q and ^S) so they will be
280 caught by the terminal.
281
282 -q, --indicator
283 Display a "scrollbar" on the righthand side of the edit window.
284 It shows the position of the viewport in the buffer and how much
285 of the buffer is covered by the viewport.
286
287 -r number, --fill=number
288 Set the target width for justifying and automatic hard-wrapping
289 at this number of columns. If the value is 0 or less, wrapping
290 will occur at the width of the screen minus number columns, al‐
291 lowing the wrap point to vary along with the width of the screen
292 if the screen is resized. The default value is -8.
293
294 -s "program [argument ...]", --speller="program [argument ...]"
295 Use this command to perform spell checking and correcting, in‐
296 stead of using the built-in corrector that calls hunspell(1) or
297 spell(1).
298
299 -t, --saveonexit
300 Save a changed buffer without prompting (when exiting with ^X).
301 (The old form of the long option, --tempfile, is deprecated.)
302
303 -u, --unix
304 Save a file by default in Unix format. This overrides nano's
305 default behavior of saving a file in the format that it had.
306 (This option has no effect when you also use --noconvert.)
307
308 -v, --view
309 Just view the file and disallow editing: read-only mode. This
310 mode allows the user to open also other files for viewing, un‐
311 less --restricted is given too.
312
313 -w, --nowrap
314 Do not automatically hard-wrap the current line when it becomes
315 overlong. This is the default. (This option is the opposite of
316 -b (--breaklonglines) -- the last one given takes effect.)
317
318 -x, --nohelp
319 Don't show the two help lines at the bottom of the screen.
320
321 -y, --afterends
322 Make Ctrl+Right and Ctrl+Delete stop at word ends instead of be‐
323 ginnings.
324
325 -z, --suspendable
326 Obsolete option; ignored. Suspension is enabled by default,
327 reachable via ^T^Z. (If you want a plain ^Z to suspend nano,
328 add bind ^Z suspend main to your nanorc.)
329
330 -%, --stateflags
331 Use the top-right corner of the screen for showing some state
332 flags: I when auto-indenting, M when the mark is on, L when
333 hard-wrapping (breaking long lines), R when recording a macro,
334 and S when soft-wrapping. When the buffer is modified, a star
335 (*) is shown after the filename in the center of the title bar.
336
337 -_, --minibar
338 Suppress the title bar and instead show information about the
339 current buffer at the bottom of the screen, in the space for the
340 status bar. In this "minibar" the filename is shown on the
341 left, followed by an asterisk if the buffer has been modified.
342 On the right are displayed the current line and column number,
343 the code of the character under the cursor (in Unicode format:
344 U+xxxx), the same flags as are shown by --stateflags, and a per‐
345 centage that expresses how far the cursor is into the file
346 (linewise). When a file is loaded or saved, and also when
347 switching between buffers, the number of lines in the buffer is
348 displayed after the filename. This number is cleared upon the
349 next keystroke, or replaced with an [i/n] counter when multiple
350 buffers are open. The line plus column numbers and the charac‐
351 ter code are displayed only when --constantshow is used, and can
352 be toggled on and off with M-C. The state flags are displayed
353 only when --stateflags is used.
354
355 -0, --zero
356 Hide all elements of the interface (title bar, status bar, and
357 help lines) and use all rows of the terminal for showing the
358 contents of the buffer. The status bar appears only when there
359 is a significant message, and disappears after 1.5 seconds or
360 upon the next keystroke. With M-Z the title bar plus status bar
361 can be toggled. With M-X the help lines.
362
363 -!, --magic
364 When neither the file's name nor its first line give a clue, try
365 using libmagic to determine the applicable syntax.
366
367
369 Several of the above options can be switched on and off also while nano
370 is running. For example, M-L toggles the hard-wrapping of long lines,
371 M-S toggles soft-wrapping, M-N toggles line numbers, M-M toggles the
372 mouse, M-I auto-indentation, and M-X the help lines. See at the end of
373 the ^G help text for a complete list.
374
375 The M-X toggle is special: it works in all menus except the help viewer
376 and the linter. All other toggles work in the main menu only.
377
378
380 When --rcfile is given, nano will read just the specified file for set‐
381 ting its options and syntaxes and key bindings. Without that option,
382 nano will read two configuration files: first the system's nanorc (if
383 it exists), and then the user's nanorc (if it exists), either ~/.nanorc
384 or $XDG_CONFIG_HOME/nano/nanorc or ~/.config/nano/nanorc, whichever is
385 encountered first. See nanorc(5) for more information on the possible
386 contents of those files.
387
388 See /usr/share/nano/ and /usr/share/nano/extra/ for available syntax-
389 coloring definitions.
390
391
393 If no alternative spell checker command is specified on the command
394 line nor in one of the nanorc files, nano will check the SPELL environ‐
395 ment variable for one.
396
397 In some cases nano will try to dump the buffer into an emergency file.
398 This will happen mainly if nano receives a SIGHUP or SIGTERM or runs
399 out of memory. It will write the buffer into a file named nano.save if
400 the buffer didn't have a name already, or will add a ".save" suffix to
401 the current filename. If an emergency file with that name already ex‐
402 ists in the current directory, it will add ".save" plus a number (e.g.
403 ".save.1") to the current filename in order to make it unique. In
404 multibuffer mode, nano will write all the open buffers to their respec‐
405 tive emergency files.
406
407
409 The recording and playback of keyboard macros works correctly only on a
410 terminal emulator, not on a Linux console (VT), because the latter does
411 not by default distinguish modified from unmodified arrow keys.
412
413 Please report any other bugs that you encounter via:
414 https://savannah.gnu.org/bugs/?group=nano.
415
416 When nano crashes, it will save any modified buffers to emergency .save
417 files. If you are able to reproduce the crash and you want to get a
418 backtrace, define the environment variable NANO_NOCATCH.
419
420
422 https://nano-editor.org/
423
424
426 nanorc(5)
427
428 /usr/share/doc/nano/ (or equivalent on your system)
429
430
431
432December 2021 version 6.0 NANO(1)