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