1NANO(1)                     General Commands Manual                    NANO(1)
2
3
4

NAME

6       nano - Nano's ANOther editor, inspired by Pico
7
8

SYNOPSIS

10       nano [options] [[+line[,column]] file]...
11
12       nano [options] [[+[crCR](/|?)string] file]...
13
14

DESCRIPTION

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

EDITING

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

OPTIONS

67       -A, --smarthome
68              Make the Home key smarter.  When Home is pressed anywhere but at
69              the  very  beginning of non-whitespace characters on a line, the
70              cursor will jump to that beginning  (either  forwards  or  back‐
71              wards).  If the cursor is already at that position, it will jump
72              to the true beginning of the line.
73
74       -B, --backup
75              When saving a file, back up the previous version  of  it,  using
76              the current filename suffixed with a tilde (~).
77
78       -C directory, --backupdir=directory
79              Make  and  keep  not  just  one backup file, but make and keep a
80              uniquely numbered one every time a file is saved -- when backups
81              are enabled (-B).  The uniquely numbered files are stored in the
82              specified directory.
83
84       -D, --boldtext
85              For the interface, use bold instead of reverse video.  This will
86              be  overridden  by  setting the options titlecolor, statuscolor,
87              keycolor, functioncolor, numbercolor,  and/or  selectedcolor  in
88              your nanorc file.  See nanorc(5).
89
90       -E, --tabstospaces
91              Convert each typed tab to spaces -- to the number of spaces that
92              a tab at that position would take up.
93
94       -F, --multibuffer
95              Read a file into a new buffer by default.
96
97       -G, --locking
98              Use vim-style file locking when editing files.
99
100       -H, --historylog
101              Save the last hundred search strings and replacement strings and
102              executed  commands,  so  they can be easily reused in later ses‐
103              sions.
104
105       -I, --ignorercfiles
106              Don't look at the system's nanorc nor at the user's nanorc.
107
108       -J number, --guidestripe=number
109              Draw a vertical stripe at the given column, to  help  judge  the
110              width of the text.  (The color of the stripe can be changed with
111              set stripecolor in your nanorc file.)
112
113       -K, --rawsequences
114              Interpret escape sequences directly, instead of  asking  ncurses
115              to translate them.  (If you need this option to get some keys to
116              work properly, it means that the terminfo  terminal  description
117              that  is  used  does not fully match the actual behavior of your
118              terminal.  This can happen when you ssh into a BSD machine,  for
119              example.)  Using this option disables nano's mouse support.
120
121       -L, --nonewlines
122              Don't  automatically add a newline when a text does not end with
123              one.  (This can cause you to save non-POSIX text files.)
124
125       -M, --trimblanks
126              Snip trailing whitespace from the wrapped  line  when  automatic
127              hard-wrapping occurs or when text is justified.
128
129       -N, --noconvert
130              Disable automatic conversion of files from DOS/Mac format.
131
132       -O, --bookstyle
133              When  justifying,  treat any line that starts with whitespace as
134              the beginning of a paragraph (unless auto-indenting is on).
135
136       -P, --positionlog
137              For the 200 most recent files, log the last position of the cur‐
138              sor,  and  place it at that position again upon reopening such a
139              file.
140
141       -Q "regex", --quotestr="regex"
142              Set the regular expression for matching the quoting  part  of  a
143              line.   The default value is "^([ \t]*([!#%:;>|}]|//))+".  (Note
144              that \t stands for an actual Tab.)  This makes  it  possible  to
145              rejustify blocks of quoted text when composing email, and to re‐
146              wrap blocks of line comments when writing source code.
147
148       -R, --restricted
149              Restricted mode: don't read or write to any file  not  specified
150              on  the  command  line.  This means: don't read or write history
151              files; don't allow suspending; don't allow spell checking; don't
152              allow  a  file to be appended to, prepended to, or saved under a
153              different name if it already has  one;  and  don't  make  backup
154              files.   Restricted  mode can also be activated by invoking nano
155              with any name beginning with 'r' (e.g. "rnano").
156
157       -S, --softwrap
158              Display over multiple screen rows lines that exceed the screen's
159              width.  (You can make this soft-wrapping occur at whitespace in‐
160              stead of rudely at the screen's edge, by using also --atblanks.)
161              (The old short option, -$, is deprecated.)
162
163       -T number, --tabsize=number
164              Set  the  size (width) of a tab to number columns.  The value of
165              number must be greater than 0.  The default value is 8.
166
167       -U, --quickblank
168              Make status-bar messages disappear after 1 keystroke instead  of
169              after  20.  Note that option -c (--constantshow) overrides this.
170              When option --minibar or --zero is in effect, --quickblank makes
171              a  message  disappear after 0.8 seconds instead of after the de‐
172              fault 1.5 seconds.
173
174       -V, --version
175              Show the current version number and exit.
176
177       -W, --wordbounds
178              Detect word boundaries differently by treating punctuation char‐
179              acters as part of a word.
180
181       -X "characters", --wordchars="characters"
182              Specify  which other characters (besides the normal alphanumeric
183              ones) should be considered as part of a word.  When  using  this
184              option, you probably want to omit -W (--wordbounds).
185
186       -Y name, --syntax=name
187              Specify  the  name  of the syntax highlighting to use from among
188              the ones defined in the nanorc files.
189
190       -Z, --zap
191              Let an unmodified Backspace or Delete erase  the  marked  region
192              (instead  of  a single character, and without affecting the cut‐
193              buffer).
194
195       -a, --atblanks
196              When doing soft line wrapping, wrap lines at whitespace  instead
197              of always at the edge of the screen.
198
199       -b, --breaklonglines
200              Automatically  hard-wrap  the current line when it becomes over‐
201              long.  (This option is the opposite of -w (--nowrap) -- the last
202              one given takes effect.)
203
204       -c, --constantshow
205              Constantly  show  the  cursor  position on the status bar.  Note
206              that this overrides option -U (--quickblank).
207
208       -d, --rebinddelete
209              Interpret the Delete and Backspace keys differently so that both
210              Backspace  and  Delete  work properly.  You should only use this
211              option when on your system either Backspace acts like Delete  or
212              Delete acts like Backspace.
213
214       -e, --emptyline
215              Do  not  use  the  line below the title bar, leaving it entirely
216              blank.
217
218       -f file, --rcfile=file
219              Read only this file for setting nano's options, instead of read‐
220              ing both the system-wide and the user's nanorc files.
221
222       -g, --showcursor
223              Make  the  cursor visible in the file browser (putting it on the
224              highlighted item) and in the help viewer.   Useful  for  braille
225              users and people with poor vision.
226
227       -h, --help
228              Show a summary of the available command-line options and exit.
229
230       -i, --autoindent
231              Automatically  indent a newly created line to the same number of
232              tabs and/or spaces as the previous line (or as the next line  if
233              the previous line is the beginning of a paragraph).
234
235       -j, --jumpyscrolling
236              Scroll the buffer contents per half-screen instead of per line.
237
238       -k, --cutfromcursor
239              Make  the  'Cut Text' command (normally ^K) cut from the current
240              cursor position to the end of the line, instead of  cutting  the
241              entire line.
242
243       -l, --linenumbers
244              Display  line  numbers  to the left of the text area.  (Any line
245              with an anchor additionally gets a mark in the margin.)
246
247       -m, --mouse
248              Enable mouse support, if available for your  system.   When  en‐
249              abled,  mouse  clicks  can  be used to place the cursor, set the
250              mark (with a double click), and execute  shortcuts.   The  mouse
251              will work in the X Window System, and on the console when gpm is
252              running.  Text can still be selected through dragging by holding
253              down the Shift key.
254
255       -n, --noread
256              Treat  any  name  given on the command line as a new file.  This
257              allows nano to write to named pipes: it will start with a  blank
258              buffer,  and  will  write  to  the  pipe when the user saves the
259              "file".  This way nano can be used as an editor  in  combination
260              with  for instance gpg without having to write sensitive data to
261              disk first.
262
263       -o directory, --operatingdir=directory
264              Set the operating directory.  This makes nano set  up  something
265              similar to a chroot.
266
267       -p, --preserve
268              Preserve  the XON and XOFF sequences (^Q and ^S) so they will be
269              caught by the terminal.
270
271       -q, --indicator
272              Display a "scrollbar" on the righthand side of the edit  window.
273              It shows the position of the viewport in the buffer and how much
274              of the buffer is covered by the viewport.
275
276       -r number, --fill=number
277              Set the target width for justifying and automatic  hard-wrapping
278              at  this number of columns.  If the value is 0 or less, wrapping
279              will occur at the width of the screen minus number columns,  al‐
280              lowing the wrap point to vary along with the width of the screen
281              if the screen is resized.  The default value is -8.
282
283       -s "program [argument ...]", --speller="program [argument ...]"
284              Use this command to perform spell checking and  correcting,  in‐
285              stead  of using the built-in corrector that calls hunspell(1) or
286              spell(1).
287
288       -t, --saveonexit
289              Save a changed buffer without prompting (when exiting with ^X).
290
291       -u, --unix
292              Save a file by default in Unix format.   This  overrides  nano's
293              default  behavior  of  saving  a file in the format that it had.
294              (This option has no effect when you also use --noconvert.)
295
296       -v, --view
297              Just view the file and disallow editing: read-only  mode.   This
298              mode  allows  the user to open also other files for viewing, un‐
299              less --restricted is given too.
300
301       -w, --nowrap
302              Do not automatically hard-wrap the current line when it  becomes
303              overlong.  This is the default.  (This option is the opposite of
304              -b (--breaklonglines) -- the last one given takes effect.)
305
306       -x, --nohelp
307              Don't show the two help lines at the bottom of the screen.
308
309       -y, --afterends
310              Make Ctrl+Right and Ctrl+Delete stop at word ends instead of be‐
311              ginnings.
312
313       -%, --stateflags
314              Use  the  top-right  corner of the screen for showing some state
315              flags: I when auto-indenting, M when the  mark  is  on,  L  when
316              hard-wrapping  (breaking  long lines), R when recording a macro,
317              and S when soft-wrapping.  When the buffer is modified,  a  star
318              (*) is shown after the filename in the center of the title bar.
319
320       -_, --minibar
321              Suppress  the  title  bar and instead show information about the
322              current buffer at the bottom of the screen, in the space for the
323              status  bar.   In  this  "minibar"  the filename is shown on the
324              left, followed by an asterisk if the buffer has  been  modified.
325              On  the  right are displayed the current line and column number,
326              the code of the character under the cursor (in  Unicode  format:
327              U+xxxx), the same flags as are shown by --stateflags, and a per‐
328              centage that expresses how far  the  cursor  is  into  the  file
329              (linewise).   When  a  file  is  loaded  or saved, and also when
330              switching between buffers, the number of lines in the buffer  is
331              displayed  after  the filename.  This number is cleared upon the
332              next keystroke, or replaced with an [i/n] counter when  multiple
333              buffers  are open.  The line plus column numbers and the charac‐
334              ter code are displayed only when --constantshow is used, and can
335              be  toggled  on and off with M-C.  The state flags are displayed
336              only when --stateflags is used.
337
338       -0, --zero
339              Hide all elements of the interface (title bar, status  bar,  and
340              help  lines)  and  use  all rows of the terminal for showing the
341              contents of the buffer.  The status bar appears only when  there
342              is  a  significant  message, and disappears after 1.5 seconds or
343              upon the next keystroke.  With M-Z the title bar plus status bar
344              can be toggled.  With M-X the help lines.
345
346       -!, --magic
347              When neither the file's name nor its first line give a clue, try
348              using libmagic to determine the applicable syntax.
349
350

TOGGLES

352       Several of the above options can be switched on and off also while nano
353       is  running.  For example, M-L toggles the hard-wrapping of long lines,
354       M-S toggles soft-wrapping, M-N toggles line numbers,  M-M  toggles  the
355       mouse, M-I auto-indentation, and M-X the help lines.  See at the end of
356       the ^G help text for a complete list.
357
358       The M-X toggle is special: it works in all menus except the help viewer
359       and the linter.  All other toggles work in the main menu only.
360
361

FILES

363       When --rcfile is given, nano will read just the specified file for set‐
364       ting its options and syntaxes and key bindings.  Without  that  option,
365       nano  will  read two configuration files: first the system's nanorc (if
366       it exists), and then the user's nanorc (if it exists), either ~/.nanorc
367       or  $XDG_CONFIG_HOME/nano/nanorc or ~/.config/nano/nanorc, whichever is
368       encountered first.  See nanorc(5) for more information on the  possible
369       contents of those files.
370
371       See  /usr/share/nano/  and /usr/share/nano/extra/ for available syntax-
372       coloring definitions.
373
374

NOTES

376       Option -z (--suspendable) has been removed.  Suspension is  enabled  by
377       default,  reachable via ^T^Z.  (If you want a plain ^Z to suspend nano,
378       add bind ^Z suspend main to your nanorc.)
379
380       If no alternative spell checker command is  specified  on  the  command
381       line nor in one of the nanorc files, nano will check the SPELL environ‐
382       ment variable for one.
383
384       In some cases nano will try to dump the buffer into an emergency  file.
385       This  will  happen  mainly if nano receives a SIGHUP or SIGTERM or runs
386       out of memory.  It will write the buffer into a file named nano.save if
387       the  buffer didn't have a name already, or will add a ".save" suffix to
388       the current filename.  If an emergency file with that name already  ex‐
389       ists  in the current directory, it will add ".save" plus a number (e.g.
390       ".save.1") to the current filename in order  to  make  it  unique.   In
391       multibuffer mode, nano will write all the open buffers to their respec‐
392       tive emergency files.
393
394

BUGS

396       The recording and playback of keyboard macros works correctly only on a
397       terminal emulator, not on a Linux console (VT), because the latter does
398       not by default distinguish modified from unmodified arrow keys.
399
400       Please report any other bugs that you encounter via:
401       https://savannah.gnu.org/bugs/?group=nano.
402
403       When nano crashes, it will save any modified buffers to emergency .save
404       files.   If  you  are able to reproduce the crash and you want to get a
405       backtrace, define the environment variable NANO_NOCATCH.
406
407

HOMEPAGE

409       https://nano-editor.org/
410
411

SEE ALSO

413       nanorc(5)
414
415       /usr/share/doc/nano/ (or equivalent on your system)
416
417
418
419August 2022                       version 6.4                          NANO(1)
Impressum