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 Any valid Unicode code point can be inserted into the buffer by typing
62 M-V followed by the hexadecimal digits of the code point (concluded
63 with <Space> or <Enter> when it are fewer than six digits). A literal
64 control code (except ^J) can be inserted by typing M-V followed by the
65 pertinent keystroke.
66
67 The two lines at the bottom of the screen show some important commands;
68 the built-in help (^G) lists all the available ones. The default key
69 bindings can be changed via a nanorc file -- see nanorc(5).
70
71
73 -A, --smarthome
74 Make the Home key smarter. When Home is pressed anywhere but at
75 the very beginning of non-whitespace characters on a line, the
76 cursor will jump to that beginning (either forwards or back‐
77 wards). If the cursor is already at that position, it will jump
78 to the true beginning of the line.
79
80 -B, --backup
81 When saving a file, back up the previous version of it, using
82 the current filename suffixed with a tilde (~).
83
84 -C directory, --backupdir=directory
85 Make and keep not just one backup file, but make and keep a
86 uniquely numbered one every time a file is saved -- when backups
87 are enabled (-B). The uniquely numbered files are stored in the
88 specified directory.
89
90 -D, --boldtext
91 For the interface, use bold instead of reverse video. This will
92 be overridden by setting the options titlecolor, statuscolor,
93 keycolor, functioncolor, numbercolor, and/or selectedcolor in
94 your nanorc file. See nanorc(5).
95
96 -E, --tabstospaces
97 Convert each typed tab to spaces -- to the number of spaces that
98 a tab at that position would take up.
99
100 -F, --multibuffer
101 Read a file into a new buffer by default.
102
103 -G, --locking
104 Use vim-style file locking when editing files.
105
106 -H, --historylog
107 Save the last hundred search strings and replacement strings and
108 executed commands, so they can be easily reused in later ses‐
109 sions.
110
111 -I, --ignorercfiles
112 Don't look at the system's nanorc nor at the user's nanorc.
113
114 -J number, --guidestripe=number
115 Draw a vertical stripe at the given column, to help judge the
116 width of the text. (The color of the stripe can be changed with
117 set stripecolor in your nanorc file.)
118
119 -K, --rawsequences
120 Interpret escape sequences directly, instead of asking ncurses
121 to translate them. (If you need this option to get some keys to
122 work properly, it means that the terminfo terminal description
123 that is used does not fully match the actual behavior of your
124 terminal. This can happen when you ssh into a BSD machine, for
125 example.) Using this option disables nano's mouse support.
126
127 -L, --nonewlines
128 Don't automatically add a newline when a text does not end with
129 one. (This can cause you to save non-POSIX text files.)
130
131 -M, --trimblanks
132 Snip trailing whitespace from the wrapped line when automatic
133 hard-wrapping occurs or when text is justified.
134
135 -N, --noconvert
136 Disable automatic conversion of files from DOS/Mac format.
137
138 -O, --bookstyle
139 When justifying, treat any line that starts with whitespace as
140 the beginning of a paragraph (unless auto-indenting is on).
141
142 -P, --positionlog
143 For the 200 most recent files, log the last position of the cur‐
144 sor, and place it at that position again upon reopening such a
145 file.
146
147 -Q "regex", --quotestr="regex"
148 Set the regular expression for matching the quoting part of a
149 line. The default value is "^([ \t]*([!#%:;>|}]|//))+". (Note
150 that \t stands for an actual Tab.) This makes it possible to
151 rejustify blocks of quoted text when composing email, and to re‐
152 wrap blocks of line comments when writing source code.
153
154 -R, --restricted
155 Restricted mode: don't read or write to any file not specified
156 on the command line. This means: don't read or write history
157 files; don't allow suspending; don't allow spell checking; don't
158 allow a file to be appended to, prepended to, or saved under a
159 different name if it already has one; and don't make backup
160 files. Restricted mode can also be activated by invoking nano
161 with any name beginning with 'r' (e.g. "rnano").
162
163 -S, --softwrap
164 Display over multiple screen rows lines that exceed the screen's
165 width. (You can make this soft-wrapping occur at whitespace in‐
166 stead of rudely at the screen's edge, by using also --atblanks.)
167 (The old short option, -$, is deprecated.)
168
169 -T number, --tabsize=number
170 Set the size (width) of a tab to number columns. The value of
171 number must be greater than 0. The default value is 8.
172
173 -U, --quickblank
174 Make status-bar messages disappear after 1 keystroke instead of
175 after 20. Note that option -c (--constantshow) overrides this.
176 When option --minibar or --zero is in effect, --quickblank makes
177 a message disappear after 0.8 seconds instead of after the de‐
178 fault 1.5 seconds.
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
297 -u, --unix
298 Save a file by default in Unix format. This overrides nano's
299 default behavior of saving a file in the format that it had.
300 (This option has no effect when you also use --noconvert.)
301
302 -v, --view
303 Just view the file and disallow editing: read-only mode. This
304 mode allows the user to open also other files for viewing, un‐
305 less --restricted is given too.
306
307 -w, --nowrap
308 Do not automatically hard-wrap the current line when it becomes
309 overlong. This is the default. (This option is the opposite of
310 -b (--breaklonglines) -- the last one given takes effect.)
311
312 -x, --nohelp
313 Don't show the two help lines at the bottom of the screen.
314
315 -y, --afterends
316 Make Ctrl+Right and Ctrl+Delete stop at word ends instead of be‐
317 ginnings.
318
319 -!, --magic
320 When neither the file's name nor its first line give a clue, try
321 using libmagic to determine the applicable syntax.
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 filename 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 filename. 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 -0, --zero
349 Hide all elements of the interface (title bar, status bar, and
350 help lines) and use all rows of the terminal for showing the
351 contents of the buffer. The status bar appears only when there
352 is a significant message, and disappears after 1.5 seconds or
353 upon the next keystroke. With M-Z the title bar plus status bar
354 can be toggled. With M-X the help lines.
355
356
358 Several of the above options can be switched on and off also while nano
359 is running. For example, M-L toggles the hard-wrapping of long lines,
360 M-S toggles soft-wrapping, M-N toggles line numbers, M-M toggles the
361 mouse, M-I auto-indentation, and M-X the help lines. See at the end of
362 the ^G help text for a complete list.
363
364 The M-X toggle is special: it works in all menus except the help viewer
365 and the linter. All other toggles work in the main menu only.
366
367
369 When --rcfile is given, nano will read just the specified file for set‐
370 ting its options and syntaxes and key bindings. Without that option,
371 nano will read two configuration files: first the system's nanorc (if
372 it exists), and then the user's nanorc (if it exists), either ~/.nanorc
373 or $XDG_CONFIG_HOME/nano/nanorc or ~/.config/nano/nanorc, whichever is
374 encountered first. See nanorc(5) for more information on the possible
375 contents of those files.
376
377 See /usr/share/nano/ and /usr/share/nano/extra/ for available syntax-
378 coloring definitions.
379
380
382 Option -z (--suspendable) has been removed. Suspension is enabled by
383 default, reachable via ^T^Z. (If you want a plain ^Z to suspend nano,
384 add bind ^Z suspend main to your nanorc.)
385
386 If no alternative spell checker command is specified on the command
387 line nor in one of the nanorc files, nano will check the SPELL environ‐
388 ment variable for one.
389
390 In some cases nano will try to dump the buffer into an emergency file.
391 This will happen mainly if nano receives a SIGHUP or SIGTERM or runs
392 out of memory. It will write the buffer into a file named nano.save if
393 the buffer didn't have a name already, or will add a ".save" suffix to
394 the current filename. If an emergency file with that name already ex‐
395 ists in the current directory, it will add ".save" plus a number (e.g.
396 ".save.1") to the current filename in order to make it unique. In
397 multibuffer mode, nano will write all the open buffers to their respec‐
398 tive emergency files.
399
400
402 The recording and playback of keyboard macros works correctly only on a
403 terminal emulator, not on a Linux console (VT), because the latter does
404 not by default distinguish modified from unmodified arrow keys.
405
406 Please report any other bugs that you encounter via:
407 https://savannah.gnu.org/bugs/?group=nano.
408
409 When nano crashes, it will save any modified buffers to emergency .save
410 files. If you are able to reproduce the crash and you want to get a
411 backtrace, define the environment variable NANO_NOCATCH.
412
413
415 https://nano-editor.org/
416
417
419 nanorc(5)
420
421 /usr/share/doc/nano/ (or equivalent on your system)
422
423
424
425January 2023 version 7.2 NANO(1)