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
14 Starting with version 4.0, nano no longer hard-wraps an overlong line
15 by default. It further uses smooth scrolling by default, and by
16 default includes the line below the title bar into the editing area.
17
18 If you want the old, Pico behavior back, you can use --breaklonglines,
19 --jumpyscrolling, and --emptyline (or -bje for short).
20
21
23 nano is a small and friendly editor. It copies the look and feel of
24 Pico, but is free software, and implements several features that Pico
25 lacks, such as: opening multiple files, scrolling per line, undo/redo,
26 syntax coloring, line numbering, and soft-wrapping overlong lines.
27
28 When giving a filename on the command line, the cursor can be put on a
29 specific line by adding the line number with a plus sign (+) before the
30 filename, and even in a specific column by adding it with a comma.
31
32 As a special case: if instead of a filename a dash (-) is given, nano
33 will read data from standard input.
34
35
37 Entering text and moving around in a file is straightforward: typing
38 the letters and using the normal cursor movement keys. Commands are
39 entered by using the Control (^) and the Alt or Meta (M-) keys. Typing
40 ^K deletes the current line and puts it in the cutbuffer. Consecutive
41 ^Ks will put all deleted lines together in the cutbuffer. Any cursor
42 movement or executing any other command will cause the next ^K to over‐
43 write the cutbuffer. A ^U will paste the current contents of the cut‐
44 buffer at the current cursor position.
45
46 When a more precise piece of text needs to be cut or copied, one can
47 mark its start with ^6, move the cursor to its end (the marked text
48 will be highlighted), and then use ^K to cut it, or M-6 to copy it to
49 the cutbuffer. One can also save the marked text to a file with ^O, or
50 spell check it with ^T.
51
52 On some terminals, text can be selected also by holding down Shift
53 while using the arrow keys. Holding down the Ctrl or Alt key too will
54 increase the stride. Any cursor movement without Shift being held will
55 cancel such a selection.
56
57 The two lines at the bottom of the screen show some important commands;
58 the built-in help (^G) lists all the available ones. The default key
59 bindings can be changed via a nanorc file -- see nanorc(5).
60
61
63 -A, --smarthome
64 Make the Home key smarter. When Home is pressed anywhere but at
65 the very beginning of non-whitespace characters on a line, the
66 cursor will jump to that beginning (either forwards or back‐
67 wards). If the cursor is already at that position, it will jump
68 to the true beginning of the line.
69
70 -B, --backup
71 When saving a file, back up the previous version of it, using
72 the current filename suffixed with a tilde (~).
73
74 -C directory, --backupdir=directory
75 Make and keep not just one backup file, but make and keep a
76 uniquely numbered one every time a file is saved -- when backups
77 are enabled (-B). The uniquely numbered files are stored in the
78 specified directory.
79
80 -D, --boldtext
81 Use bold text instead of reverse video text.
82
83 -E, --tabstospaces
84 Convert typed tabs to spaces.
85
86 -F, --multibuffer
87 Read a file into a new buffer by default.
88
89 -G, --locking
90 Use vim-style file locking when editing files.
91
92 -H, --historylog
93 Save the last hundred search strings and replacement strings and
94 executed commands, so they can be easily reused in later ses‐
95 sions.
96
97 -I, --ignorercfiles
98 Don't look at the system's nanorc nor at the user's nanorc.
99
100 -J number, --guidestripe=number
101 Draw a vertical stripe at the given column, to help judge the
102 width of the text. (The color of the stripe can be changed with
103 set stripecolor in your nanorc file.)
104
105 -K, --rawsequences
106 Interpret escape sequences directly (instead of asking ncurses
107 to translate them). If you need this option to get your key‐
108 board to work properly, please report a bug. Using this option
109 disables nano's mouse support.
110
111 -L, --nonewlines
112 Don't automatically add a newline when a text does not end with
113 one. (This can cause you to save non-POSIX text files.)
114
115 -M, --trimblanks
116 Snip trailing whitespace from the wrapped line when automatic
117 hard-wrapping occurs or when text is justified.
118
119 -N, --noconvert
120 Disable automatic conversion of files from DOS/Mac format.
121
122 -O, --morespace
123 Obsolete and ignored option, since the line below the title bar
124 is included into the editing space by default. If you prefer to
125 keep this line blank, use -e or --emptyline.
126
127 -P, --positionlog
128 For the 200 most recent files, log the last position of the cur‐
129 sor, and place it at that position again upon reopening such a
130 file.
131
132 -Q "regex", --quotestr="regex"
133 Set the regular expression for matching the quoting part of a
134 line. The default value is "^([ \t]*([!#%:;>|}]|//))+". (Note
135 that \t stands for an actual Tab.) This makes it possible to
136 rejustify blocks of quoted text when composing email, and to re‐
137 wrap blocks of line comments when writing source code.
138
139 -R, --restricted
140 Restricted mode: don't read or write to any file not specified
141 on the command line. This means: don't read or write history
142 files; don't allow suspending; don't allow spell checking; don't
143 allow a file to be appended to, prepended to, or saved under a
144 different name if it already has one; and don't make backup
145 files. Restricted mode can also be activated by invoking nano
146 with any name beginning with 'r' (e.g. "rnano").
147
148 -S, --smooth
149 Obsolete and ignored option, since smooth scrolling has become
150 the default. If you prefer the chunk-by-chunk scrolling behav‐
151 ior, use -j or --jumpyscrolling.
152
153 -T number, --tabsize=number
154 Set the size (width) of a tab to number columns. The value of
155 number must be greater than 0. The default value is 8.
156
157 -U, --quickblank
158 Do quick status-bar blanking: status-bar messages will disappear
159 after 1 keystroke instead of 25. Note that option -c (--con‐
160 stantshow) overrides this.
161
162 -V, --version
163 Show the current version number and exit.
164
165 -W, --wordbounds
166 Detect word boundaries differently by treating punctuation char‐
167 acters as part of a word.
168
169 -X "characters", --wordchars="characters"
170 Specify which other characters (besides the normal alphanumeric
171 ones) should be considered as part of a word. This overrides
172 option -W (--wordbounds).
173
174 -Y name, --syntax=name
175 Specify the name of the syntax highlighting to use from among
176 the ones defined in the nanorc files.
177
178 -Z, --zap
179 Let an unmodified Backspace or Delete erase the marked region
180 (instead of a single character, and without affecting the cut‐
181 buffer).
182
183 -a, --atblanks
184 When doing soft line wrapping, wrap lines at whitespace instead
185 of always at the edge of the screen.
186
187 -b, --breaklonglines
188 Automatically hard-wrap the current line when it becomes over‐
189 long. (This option is the opposite of -w (--nowrap) -- the last
190 one given takes effect.)
191
192 -c, --constantshow
193 Constantly show the cursor position on the status bar. Note
194 that this overrides option -U (--quickblank).
195
196 -d, --rebinddelete
197 Interpret the Delete and Backspace keys differently so that both
198 Backspace and Delete work properly. You should only use this
199 option when on your system either Backspace acts like Delete or
200 Delete acts like Backspace.
201
202 -e, --emptyline
203 Do not use the line below the title bar, leaving it entirely
204 blank.
205
206 -g, --showcursor
207 Make the cursor visible in the file browser (putting it on the
208 highlighted item) and in the help viewer. Useful for braille
209 users and people with poor vision.
210
211 -h, --help
212 Show a summary of the available command-line options and exit.
213
214 -i, --autoindent
215 Automatically indent a newly created line to the same number of
216 tabs and/or spaces as the previous line (or as the next line if
217 the previous line is the beginning of a paragraph).
218
219 -j, --jumpyscrolling
220 Scroll the buffer contents per half-screen instead of per line.
221
222 -k, --cutfromcursor
223 Make the 'Cut Text' command (normally ^K) cut from the current
224 cursor position to the end of the line, instead of cutting the
225 entire line.
226
227 -l, --linenumbers
228 Display line numbers to the left of the text area.
229
230 -m, --mouse
231 Enable mouse support, if available for your system. When
232 enabled, mouse clicks can be used to place the cursor, set the
233 mark (with a double click), and execute shortcuts. The mouse
234 will work in the X Window System, and on the console when gpm is
235 running. Text can still be selected through dragging by holding
236 down the Shift key.
237
238 -n, --noread
239 Treat any name given on the command line as a new file. This
240 allows nano to write to named pipes: it will start with a blank
241 buffer, and will write to the pipe when the user saves the
242 "file". This way nano can be used as an editor in combination
243 with for instance gpg without having to write sensitive data to
244 disk first.
245
246 -o directory, --operatingdir=directory
247 Set the operating directory. This makes nano set up something
248 similar to a chroot.
249
250 -p, --preserve
251 Preserve the XON and XOFF sequences (^Q and ^S) so they will be
252 caught by the terminal.
253
254 -r number, --fill=number
255 Set the target width for justifying and automatic hard-wrapping
256 at this number of columns. If the value is 0 or less, wrapping
257 will occur at the width of the screen minus number columns,
258 allowing the wrap point to vary along with the width of the
259 screen if the screen is resized. The default value is -8.
260
261 -s program, --speller=program
262 Use this alternative spell checker command.
263
264 -t, --tempfile
265 Save a changed buffer without prompting (when exiting with ^X).
266
267 -u, --unix
268 Save a file by default in Unix format. This overrides nano's
269 default behavior of saving a file in the format that it had.
270 (This option has no effect when you also use --noconvert.)
271
272 -v, --view
273 Just view the file and disallow editing: read-only mode. This
274 mode allows the user to open also other files for viewing,
275 unless --restricted is given too.
276
277 -w, --nowrap
278 Do not automatically hard-wrap the current line when it becomes
279 overlong. This is the default. (This option is the opposite of
280 -b (--breaklonglines) -- the last one given takes effect.)
281
282
283 -x, --nohelp
284 Don't show the two help lines at the bottom of the screen.
285
286 -y, --afterends
287 Make Ctrl+Right stop at word ends instead of beginnings.
288
289 -z, --suspend
290 Enable the suspend ability.
291
292 -$, --softwrap
293 Enable 'soft wrapping'. This will make nano attempt to display
294 the entire contents of any line, even if it is longer than the
295 screen width, by continuing it over multiple screen lines.
296 Since '$' normally refers to a variable in the Unix shell, you
297 should specify this option last when using other options (e.g.
298 'nano -wS$') or pass it separately (e.g. 'nano -wS -$').
299
300
302 Several of the above options can be switched on and off also while nano
303 is running. For example, M-L toggles the hard-wrapping of long lines,
304 M-S toggles soft-wrapping, M-N toggles line numbers, M-M toggles the
305 mouse, M-I auto-indentation, and M-X the help lines. See at the end of
306 the ^G help text for a complete list.
307
308
310 nano will read two configuration files: first the system's nanorc (if
311 it exists), and then the user's nanorc (if it exists), either ~/.nanorc
312 or $XDG_CONFIG_HOME/nano/nanorc or ~/.config/nano/nanorc, whichever is
313 encountered first. See nanorc(5) for more information on the possible
314 contents of those files.
315
316
318 If no alternative spell checker command is specified on the command
319 line nor in one of the nanorc files, nano will check the SPELL environ‐
320 ment variable for one.
321
322 In some cases nano will try to dump the buffer into an emergency file.
323 This will happen mainly if nano receives a SIGHUP or SIGTERM or runs
324 out of memory. It will write the buffer into a file named nano.save if
325 the buffer didn't have a name already, or will add a ".save" suffix to
326 the current filename. If an emergency file with that name already
327 exists in the current directory, it will add ".save" plus a number
328 (e.g. ".save.1") to the current filename in order to make it unique.
329 In multibuffer mode, nano will write all the open buffers to their
330 respective emergency files.
331
332
334 The recording and playback of keyboard macros works correctly only on a
335 terminal emulator, not on a Linux console (VT), because the latter does
336 not by default distinguish modified from unmodified arrow keys.
337
338 Please report any other bugs that you encounter via:
339 https://savannah.gnu.org/bugs/?group=nano.
340
341 When nano crashes, it will save any modified buffers to emergency .save
342 files. If you are able to reproduce the crash and you want to get a
343 backtrace, define the environment variable NANO_NOCATCH.
344
345
347 https://nano-editor.org/
348
349
351 nanorc(5)
352
353 /usr/share/doc/nano/ (or equivalent on your system)
354
355
356
357June 2019 version 4.3 NANO(1)