nano.texi 54.9 KB
Newer Older
Chris Allegretta's avatar
Chris Allegretta committed
1
2
3
\input texinfo  @c -*-texinfo-*-
@c %**start of header
@setfilename nano.info
4
@settitle nano
Chris Allegretta's avatar
Chris Allegretta committed
5
6
@c %**end of header

7
8
@documentencoding UTF-8

Chris Allegretta's avatar
Chris Allegretta committed
9
@smallbook
10
@set EDITION 0.5
11
12
@set VERSION 2.9.6
@set UPDATED April 2018
Chris Allegretta's avatar
Chris Allegretta committed
13

14
15
@dircategory Editors
@direntry
Chris Allegretta's avatar
Chris Allegretta committed
16
* nano: (nano).                 Small and friendly text editor.
17
@end direntry
Chris Allegretta's avatar
Chris Allegretta committed
18
19
20
21
22
23

@c tex
@c \overfullrule=0pt
@c end tex

@titlepage
24
@title GNU @command{nano}
25
@subtitle a small and friendly text editor
26
@subtitle version 2.9.6
Chris Allegretta's avatar
Chris Allegretta committed
27
28
29
30

@author Chris Allegretta
@page

31
32
This manual documents the GNU @command{nano} editor.
@sp 1
33
This manual is part of the GNU @command{nano} distribution.@*
34

35
@sp 4
36
Copyright @copyright{} 1999-2009, 2014-2017 Free Software Foundation, Inc.
Chris Allegretta's avatar
Chris Allegretta committed
37

38
@sp 1
39
40
41
This document is dual-licensed.  You may distribute and/or modify it
under the terms of either of the following licenses:

42
@sp 1
43
44
45
* The GNU General Public License, as published by the Free Software
  Foundation, version 3 or (at your option) any later version.  You
  should have received a copy of the GNU General Public License along
46
  with this program.  If not, see @url{http://www.gnu.org/licenses/}.
47

48
@sp 1
49
50
51
52
* The GNU Free Documentation License, as published by the Free Software
  Foundation, version 1.2 or (at your option) any later version, with no
  Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
  You should have received a copy of the GNU Free Documentation License
53
  along with this program.  If not, see @url{http://www.gnu.org/licenses/}.
Chris Allegretta's avatar
Chris Allegretta committed
54

55
@sp 1
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
56
You may contact the author by
Chris Allegretta's avatar
Chris Allegretta committed
57
58
59
e-mail: @email{chrisa@@asty.org}@*
@end titlepage

60

61
62
@ifnottex

63
64
@node Top
@top
Chris Allegretta's avatar
Chris Allegretta committed
65

66
This manual documents the GNU @command{nano} editor, version 2.9.6.
Chris Allegretta's avatar
Chris Allegretta committed
67
68
69

@menu
* Introduction::
70
71
* Invoking::
* Command-line Options::
Chris Allegretta's avatar
Chris Allegretta committed
72
* Editor Basics::
73
* Built-in Help::
Chris Allegretta's avatar
Chris Allegretta committed
74
* Feature Toggles::
75
* Nanorc Files::
Chris Allegretta's avatar
Chris Allegretta committed
76
77
78
79
80
* The File Browser::
* Pico Compatibility::
* Building and Configure Options::
@end menu

81
82
@end ifnottex

83
84

@node Introduction
Chris Allegretta's avatar
Chris Allegretta committed
85
86
@chapter Introduction

87
88
GNU @command{nano} is a small and friendly text editor.  Besides basic text
editing, @command{nano} offers many extra features, such as an interactive
89
90
91
search-and-replace, undo/redo, syntax coloring, smooth scrolling,
auto-indentation, go-to-line-and-column-number, feature toggles,
file locking, backup files, and internationalization support.
Chris Allegretta's avatar
Chris Allegretta committed
92

93
The original goal for @command{nano} was to be a complete bug-for-bug
94
emulation of Pico.  But currently the goal is to be as compatible
95
as possible while offering a superset of Pico's functionality.
96
@xref{Pico Compatibility} for more details on how @command{nano} and
97
Pico differ.
Chris Allegretta's avatar
Chris Allegretta committed
98

99
100
Please report bugs via @url{https://savannah.gnu.org/bugs/?group=nano}.

101

102
103
104
@node Invoking
@chapter Invoking

105
The usual way to invoke @command{nano} is:
106

107
108
109
110
@iftex
@sp 1
@end iftex
@example
111
@code{nano [FILE]}
112
113
114
115
@end example
@iftex
@sp 1
@end iftex
116

117
118
119
But it is also possible to specify one or more options (see the next
section), and to edit several files in a row.  Additionally, the cursor
can be put on a specific line of a file by adding the line number
120
with a plus sign before the filename, and even in a specific column by
121
adding it with a comma.  So a more complete command synopsis is:
122

123
124
125
126
@iftex
@sp 1
@end iftex
@example
127
@code{nano [OPTION]@dots{} [[+LINE[,COLUMN]|+,COLUMN] FILE]@dots{}}
128
129
130
131
@end example
@iftex
@sp 1
@end iftex
132

133
Normally, however, you set your preferred options in a @file{nanorc}
134
file (@pxref{Nanorc Files}).  And when using @code{set positionlog}
135
(making @command{nano} remember the cursor position when you close a file),
136
you will rarely need to specify a line number.
137

138
As a special case: when instead of a filename a dash is given, @command{nano}
139
140
will read data from standard input.  This means you can pipe the output of
a command straight into a buffer, and then edit it.
141

142
143
@node Command-line Options
@chapter Command-line Options
Chris Allegretta's avatar
Chris Allegretta committed
144

145
@command{nano} takes the following options from the command line:
146

147
@table @option
148

149
150
@item -A
@itemx --smarthome
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
151
152
153
154
155
156
Make the Home key smarter.  When Home is pressed anywhere but at the
very beginning of non-whitespace characters on a line, the cursor will
jump to that beginning (either forwards or backwards).  If the cursor is
already at that position, it will jump to the true beginning of the
line.

157
158
@item -B
@itemx --backup
159
When saving a file, back up the previous version of it, using the current
160
filename suffixed with a tilde (@code{~}).
161

162
163
@item -C @var{directory}
@itemx --backupdir=@var{directory}
164
165
166
Make and keep not just one backup file, but make and keep a uniquely
numbered one every time a file is saved --- when backups are enabled.
The uniquely numbered files are stored in the specified directory.
167

168
169
@item -D
@itemx --boldtext
170
171
Use bold text instead of reverse video text.

172
173
@item -E
@itemx --tabstospaces
174
175
Convert typed tabs to spaces.

176
177
@item -F
@itemx --multibuffer
178
Read a file into a new buffer by default.
179

180
181
@item -G
@itemx --locking
182
183
Enable vim-style file locking when editing files.

184
185
@item -H
@itemx --historylog
186
187
Save the last hundred search strings and replacement strings and
executed commands, so they can be easily reused in later sessions.
188

189
190
@item -I
@itemx --ignorercfiles
191
Don't look at the system's nanorc file nor at the user's nanorc.
Chris Allegretta's avatar
Chris Allegretta committed
192

193
194
@item -K
@itemx --rebindkeypad
195
196
197
198
Interpret the numeric keypad keys so that they all work properly.  You
should only need to use this option if they don't, as mouse support
won't work properly with this option enabled.

199
200
@item -L
@itemx --nonewlines
201
202
Don't add newlines to the ends of files.

203
204
205
206
207
@item -M
@itemx --trimblanks
Snip trailing whitespace from the wrapped line when automatic
hard-wrapping occurs or when text is justified.

208
209
@item -N
@itemx --noconvert
210
Disable automatic conversion of files from DOS/Mac format.
Jordi Mallach's avatar
Jordi Mallach committed
211

212
213
@item -O
@itemx --morespace
214
Use the blank line below the title bar as extra editing space.
215

216
@item -P
217
@itemx --positionlog
218
219
For the 200 most recent files, log the last position of the cursor,
and place it at that position again upon reopening such a file.
220

221
222
@item -Q "@var{characters}"
@itemx --quotestr="@var{characters}"
223
Set the quoting string for justifying.  The default value is
224
225
226
@t{"^([ \t]*[|>:@}#])+"} if extended regular expression support
is available, and @t{"> "} otherwise.
Note that @code{\t} stands for a literal Tab character.
Jordi Mallach's avatar
Jordi Mallach committed
227

228
229
@item -R
@itemx --restricted
230
Restricted mode: don't read or write to any file not specified on the
231
232
command line; don't read any nanorc files nor history files; don't allow
suspending nor spell checking; don't
233
allow a file to be appended to, prepended to, or saved under a different
234
name if it already has one; and don't use backup files.
235
This restricted mode is also accessible by invoking @command{nano} with
236
any name beginning with @code{r} (e.g.@: @command{rnano}).
237

238
239
@item -S
@itemx --smooth
240
241
Enable smooth scrolling.  Text will scroll line-by-line, instead of the
usual chunk-by-chunk behavior.
242

243
244
245
@item -T @var{number}
@itemx --tabsize=@var{number}
Set the displayed tab length to @var{number} columns.  The value of
246
@var{number} must be greater than 0.  The default value is @t{8}.
247

248
249
@item -U
@itemx --quickblank
250
Do quick status-bar blanking: status-bar messages will disappear after 1
251
252
keystroke instead of 25.  Note that option @option{-c}
(@option{--constantshow}) overrides this.
253

254
255
@item -V
@itemx --version
256
Show the current version number and exit.
Chris Allegretta's avatar
Chris Allegretta committed
257

258
259
@item -W
@itemx --wordbounds
260
Detect word boundaries differently by treating punctuation
261
characters as parts of words.
262

263
264
265
266
267
268
@item -X "@var{characters}"
@itemx --wordchars="@var{characters}"
Specify which other characters (besides the normal alphanumeric ones)
should be considered as parts of words.  This overrides option
@option{-W} (@option{--wordbounds}).

269
270
@item -Y @var{name}
@itemx --syntax=@var{name}
271
272
Specify the syntax to be used for highlighting.
@xref{Syntax Highlighting} for more info.
273

274
275
276
277
278
@item -a
@itemx --atblanks
When doing soft line wrapping, wrap lines at whitespace
instead of always at the edge of the screen.

279
@item -c
280
@itemx --constantshow
281
282
Constantly display the cursor position (line number, column number,
and character number) on the status bar.
283
Note that this overrides option @option{-U} (@option{--quickblank}).
Chris Allegretta's avatar
Chris Allegretta committed
284

285
286
@item -d
@itemx --rebinddelete
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
287
288
289
290
Interpret the Delete key differently so that both Backspace and Delete
work properly.  You should only need to use this option if Backspace
acts like Delete on your system.

291
292
293
294
295
@item -g
@itemx --showcursor
Make the cursor visible in the file browser, putting it on the
highlighted item.  Useful for braille users.

296
297
@item -h
@itemx --help
298
Show a summary of command-line options and exit.
Chris Allegretta's avatar
Chris Allegretta committed
299

300
301
@item -i
@itemx --autoindent
Chris Allegretta's avatar
Chris Allegretta committed
302
303
304
Automatically indent new lines to the same number of spaces and tabs as
the previous line.

305
@item -k
306
@itemx --cutfromcursor
307
Make the 'Cut Text' command (normally @kbd{^K}) cut from the current cursor
308
position to the end of the line, instead of cutting the entire line.
Chris Allegretta's avatar
Chris Allegretta committed
309

310
311
312
313
@item -l
@itemx --linenumbers
Display line numbers to the left of the text area.

314
315
@item -m
@itemx --mouse
316
317
318
Enable mouse support, if available for your system.  When enabled, mouse
clicks can be used to place the cursor, set the mark (with a double
click), and execute shortcuts.  The mouse will work in the X Window
319
320
System, and on the console when gpm is running.  Text can still be
selected through dragging by holding down the Shift key.
Chris Allegretta's avatar
Chris Allegretta committed
321

322
323
@item -n
@itemx --noread
324
Treat any name given on the command line as a new file.  This allows
325
@command{nano} to write to named pipes: it will start with a blank buffer,
326
and will write to the pipe when the user saves the "file".  This way
327
328
@command{nano} can be used as an editor in combination with for instance
@command{gpg} without having to write sensitive data to disk first.
329

330
331
332
333
@item -o @var{directory}
@itemx --operatingdir=@var{directory}
Set the operating directory.  This makes @command{nano} set up something
similar to a chroot.
334

335
336
@item -p
@itemx --preserve
337
338
Preserve the @kbd{^Q} (XON) and @kbd{^S} (XOFF) sequences so data being
sent to the editor can be stopped and started.
Chris Allegretta's avatar
Chris Allegretta committed
339

340
341
@item -q
@itemx --quiet
342
Obsolete option.  Recognized but ignored.
343

344
345
346
@item -r @var{number}
@itemx --fill=@var{number}
Hard-wrap lines at column @var{number} (by inserting a newline character).
347
348
349
If the given value is 0 or less, wrapping will occur at the width of
the screen minus the given amount, allowing the wrapping width to
vary along with the width of the screen if and when it is resized.
350
351
The default value is @t{-8}.  This option conflicts with @option{-w}
(@option{--nowrap}); the last one given takes effect.
352

353
@anchor{@option{--speller}}
354
355
@item -s @var{program}
@itemx --speller=@var{program}
356
357
Use the given program to do spell checking and correcting.  By default,
@command{nano} uses the command specified in the @env{SPELL} environment
358
variable for this.  If @env{SPELL} is not set, and @option{--speller} is
359
360
not specified either, then @command{nano} uses its own interactive spell
corrector, which requires the GNU @command{spell} program to be installed.
361
362
363

@item -t
@itemx --tempfile
364
Don't ask whether to save a modified buffer when exiting with @kbd{^X}, but
365
assume yes.  This option is useful when @command{nano} is used as the
Chris Allegretta's avatar
Chris Allegretta committed
366
367
composer of a mailer program.

368
369
370
@item -u
@item --unix
Save a file by default in Unix format.  This overrides nano's
371
default behavior of saving a file in the format that it had.
372
(This option has no effect when you also use @option{--noconvert}.)
373

374
375
@item -v
@itemx --view
376
377
378
Don't allow the contents of the file to be altered.  Note that this
option should NOT be used in place of correct file permissions to
implement a read-only file.
Chris Allegretta's avatar
Chris Allegretta committed
379

380
381
@item -w
@itemx --nowrap
382
Don't hard-wrap long lines at any length.  This option conflicts with
383
@option{-r} (@option{--fill}); the last one given takes effect.
Chris Allegretta's avatar
Chris Allegretta committed
384

385
@anchor{Expert Mode}
386
387
@item -x
@itemx --nohelp
388
Expert Mode: don't show the Shortcut List at the bottom of the screen.
389
This affects the location of the status bar as well, as in Expert Mode it
390
391
392
is located at the very bottom of the editor.

Note: When accessing the help system, Expert Mode is temporarily
393
disabled to display the help-system navigation keys.
394

395
396
397
@item -z
@itemx --suspend
Enable the ability to suspend @command{nano} using the system's suspend
398
keystroke (usually @kbd{^Z}).
Chris Allegretta's avatar
Chris Allegretta committed
399

400
401
402
@item -$
@itemx --softwrap
Enable 'soft wrapping'.  This will make @command{nano} attempt to display the
403
404
entire contents of any line, even if it is longer than the screen width, by
continuing it over multiple screen lines.  Since
405
406
407
@code{$} normally refers to a variable in the Unix shell, you should specify
this option last when using other options (e.g.@: @code{nano -wS$}) or pass it
separately (e.g.@: @code{nano -wS -$}).
408

409
@item -b
410
411
412
@itemx -e
@itemx -f
@itemx -j
413
Ignored, for compatibility with Pico.
414

Chris Allegretta's avatar
Chris Allegretta committed
415
416
@end table

417

418
@node Editor Basics
Chris Allegretta's avatar
Chris Allegretta committed
419
@chapter Editor Basics
420

Chris Allegretta's avatar
Chris Allegretta committed
421
422
@menu
* Entering Text::
423
* Commands::
424
425
* The Cutbuffer::
* The Mark::
426
427
* Screen Layout::
* Search and Replace::
428
* Using the Mouse::
429
* Limitations::
Chris Allegretta's avatar
Chris Allegretta committed
430
431
@end menu

432
@node Entering Text
Chris Allegretta's avatar
Chris Allegretta committed
433
434
@section Entering Text

435
@command{nano} is a "modeless" editor.  This means that all keystrokes,
436
437
438
439
440
441
442
443
444
with the exception of Control and Meta sequences, enter text into the
file being edited.

Characters not present on the keyboard can be entered in two ways:

@itemize @bullet
@item
For characters with a single-byte code,
pressing the Esc key twice and then typing a three-digit decimal number
445
446
(from @kbd{000} to @kbd{255}) will make @command{nano} behave as if you
typed the key with that value.
447
448

@item
449
For any possible character, pressing @kbd{M-V} (Alt+V) and then typing a
450
six-digit hexadecimal number (starting with @kbd{0} or @kbd{1}) will enter the
451
corresponding Unicode character into the buffer.
452
@end itemize
Chris Allegretta's avatar
Chris Allegretta committed
453

454
455
For example, typing @kbd{Esc Esc 2 3 4} will enter the character "ê" ---
useful when writing about a French party.  Typing @kbd{M-V 0 0 2 2 c 4}
456
will enter the symbol "⋄", a little diamond.
457

458
459
@node Commands
@section Commands
Chris Allegretta's avatar
Chris Allegretta committed
460

461
462
Commands are given by using the Control key (Ctrl, shown as @kbd{^})
or the Meta key (Alt or Cmd, shown as @kbd{M-}).
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
463

Chris Allegretta's avatar
Chris Allegretta committed
464
465
@itemize @bullet
@item
466
A control-key sequence is entered by holding down the Ctrl key and
467
pressing the desired key.
468

David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
469
@item
470
471
A meta-key sequence is entered by holding down the Meta key (normally
the Alt key) and pressing the desired key.
Chris Allegretta's avatar
Chris Allegretta committed
472
473
@end itemize

474
475
476
477
478
479
If for some reason on your system the combinations with Ctrl or Alt do
not work, you can generate them by using the Esc key.  A control-key
sequence is generated by pressing the Esc key twice and then pressing
the desired key, and a meta-key sequence by pressing the Esc key once
and then pressing the desired key.

480
481
482
483
@node The Cutbuffer
@section The Cutbuffer

Text can be cut from a file, a whole line at a time, by using the 'Cut Text'
484
485
486
command (default key binding: @kbd{^K}).  The cut line is stored in
the cutbuffer.  Consecutive strokes of @kbd{^K} will add each cut line
to this buffer, but a @kbd{^K}
487
488
489
after any other keystroke will overwrite the entire cutbuffer.

The contents of the cutbuffer can be pasted back into the file with the
490
'Uncut Text' command (default key binding: @kbd{^U}).
491
492

A line of text can be copied into the cutbuffer (without cutting it) with
493
the 'Copy Text' command (default key binding: @kbd{M-6}).
494
495
496
497
498

@node The Mark
@section The Mark

Text can be selected by first 'setting the Mark' (default key bindings:
499
@kbd{^6} and @kbd{M-A}) and then moving the cursor to the other end of the portion
500
to be selected.  The selected portion of text will be highlighted.
501
This selection can now be cut or copied in its entirety with a single
502
503
@kbd{^K} or @kbd{M-6}.  Or the selection can be used to limit the scope of
a search-and-replace (@kbd{^\}) or spell-checking session (@kbd{^T}).
504

505
506
507
508
On some terminals, it is also possible to select text by holding down
@kbd{Shift} together with the cursor keys.  Such a selection is cancelled
upon any cursor movement where @kbd{Shift} isn't held.

509
Cutting or copying selected text will toggle the mark off automatically.
510
If necessary, it can be toggled off manually with another @kbd{^6} or @kbd{M-A}.
511

512
513
514
515
@node Screen Layout
@section Screen Layout

The default screen of nano consists of five areas.  From top to bottom
516
these are: the title bar, a blank line, the edit window, the status bar,
517
and two help lines.
Chris Allegretta's avatar
Chris Allegretta committed
518

519
The title bar consists of
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
520
three sections: left, center and right.  The section on the left
521
displays the version of @command{nano} being used.  The center section
522
displays the current filename, or "New Buffer" if the file has not yet
523
been named.  The section on the right displays "Modified" if the
524
file has been modified since it was last saved or opened.
Chris Allegretta's avatar
Chris Allegretta committed
525

526
The status bar is the third line from the bottom of the screen.  It
527
shows important and informational messages.  Any error messages that
528
529
530
occur from using the editor will appear on the status bar.  Any questions
that are asked of the user will be asked on the status bar, and any user
input (search strings, filenames, etc.) will be input on the status bar.
Chris Allegretta's avatar
Chris Allegretta committed
531

532
533
534
535
536
537
538
539
The two help lines at the bottom of the screen show some of the most
essential functions of the editor.  These two lines are called the
Shortcut List.

@node Search and Replace
@section Search and Replace

One can search the current buffer for the occurrence of any string
540
with the Search command (default key binding: @kbd{^W}).  The default search
541
mode is forward, case-insensitive, and for literal strings.  But one
542
543
can search backwards by pressing @kbd{M-B}, search case sensitively with @kbd{M-C},
and interpret regular expressions in the search string with @kbd{M-R}.
Chris Allegretta's avatar
Chris Allegretta committed
544

545
A regular expression in a search string always covers just one line;
546
it cannot span multiple lines.  And when replacing (with @kbd{^\} or @kbd{M-R})
547
the replacement string cannot contain a newline (LF).
Chris Allegretta's avatar
Chris Allegretta committed
548

549
@node Using the Mouse
550
551
552
553
554
@section Using the Mouse

When mouse support has been configured and enabled, a single mouse click
places the cursor at the indicated position.  Clicking a second time in
the same position toggles the mark.  Clicking in the shortcut list
555
556
557
executes the selected shortcut.  To be able to select text with the
left button, or paste text with the middle button, hold down the
Shift key during those actions.
558
559
560
561

The mouse will work in the X Window System, and on the console when gpm
is running.

562
563
@node Limitations
@section Limitations
564

565
Justifications (@kbd{^J})
566
are not yet covered by the general undo system.  So after a justification
567
that is not immediately undone, earlier edits
568
569
570
cannot be undone any more.  The workaround is, of course, to exit without
saving.

571
The recording and playback of keyboard macros works correctly only on a
572
573
terminal emulator, not on a Linux console (VT), because the latter does
not by default distinguish modified from unmodified arrow keys.
574

575
576
@node Built-in Help
@chapter Built-in Help
Chris Allegretta's avatar
Chris Allegretta committed
577

578
The built-in help system in @command{nano} is available by pressing @kbd{^G}.
579
It is fairly self-explanatory.  It documents the various parts of the
580
581
editor and the available keystrokes.  Navigation is via the @kbd{^Y} (Page Up)
and @kbd{^V} (Page Down) keys.  @kbd{^X} exits from the help system.
Chris Allegretta's avatar
Chris Allegretta committed
582
583


584
@node Feature Toggles
Chris Allegretta's avatar
Chris Allegretta committed
585
586
@chapter Feature Toggles

587
588
Toggles allow you to change on-the-fly certain aspects of the editor
which would normally be specified via command-line options.  They are
589
invoked via Meta-key sequences (@pxref{Commands} for more info).
590
The following global toggles are available:
Chris Allegretta's avatar
Chris Allegretta committed
591
592
593

@table @code

594
@item Backup Files toggle
595
@kbd{Meta-B} toggles the @option{-B} (@option{--backup}) command-line option.
Chris Allegretta's avatar
Chris Allegretta committed
596

597
@item Constant Cursor Position Display toggle
598
@kbd{Meta-C} toggles the @option{-c} (@option{--constantshow}) command-line option.
599

600
@item Multiple File Buffers toggle
601
@kbd{Meta-F} toggles the @option{-F} (@option{--multibuffer}) command-line option.
602

603
@item Smart Home Key toggle
604
@kbd{Meta-H} toggles the @option{-A} (@option{--smarthome}) command-line option.
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
605

606
@item Auto Indent toggle
607
@kbd{Meta-I} toggles the @option{-i} (@option{--autoindent}) command-line option.
Chris Allegretta's avatar
Chris Allegretta committed
608

609
@item Cut From Cursor To End-of-Line toggle
610
@kbd{Meta-K} toggles the @option{-k} (@option{--cutfromcursor}) command-line option.
Chris Allegretta's avatar
Chris Allegretta committed
611

612
@item Long-Line Wrapping toggle
613
@kbd{Meta-L} toggles the @option{-w} (@option{--nowrap}) command-line option.
614

615
@item Mouse Support toggle
616
@kbd{Meta-M} toggles the @option{-m} (@option{--mouse}) command-line option.
Chris Allegretta's avatar
Chris Allegretta committed
617

618
@item No Conversion From DOS/Mac Format toggle
619
@kbd{Meta-N} toggles the @option{-N} (@option{--noconvert}) command-line option.
620

621
@item More Space For Editing toggle
622
@kbd{Meta-O} toggles the @option{-O} (@option{--morespace}) command-line option.
623

624
625
@item Whitespace Display toggle
@kbd{Meta-P} toggles the whitespace-display mode (@pxref{Whitespace}).
626

627
@item Tabs To Spaces toggle
628
@kbd{Meta-Q} toggles the @option{-E} (@option{--tabstospaces}) command-line option.
629

630
@item Smooth Scrolling toggle
631
@kbd{Meta-S} toggles the @option{-S} (@option{--smooth}) command-line option.
632

633
@item Expert/No Help toggle
634
@kbd{Meta-X} toggles the @option{-x} (@option{--nohelp}) command-line option.
Chris Allegretta's avatar
Chris Allegretta committed
635

636
637
@item Color Syntax Highlighting toggle
@kbd{Meta-Y} toggles color syntax highlighting (if your nanorc defines syntaxes
638
--- @pxref{Syntax Highlighting}).
639

640
@item Suspension toggle
641
@kbd{Meta-Z} toggles the @option{-z} (@option{--suspend}) command-line option.
Chris Allegretta's avatar
Chris Allegretta committed
642

643
@item Line Numbers toggle
644
@kbd{Meta-#} toggles the @option{-l} (@option{--linenumbers}) command-line option.
645

646
@item Soft Wrapping toggle
647
@kbd{Meta-$} toggles the @option{-$} (@option{--softwrap}) command-line option.
648

Chris Allegretta's avatar
Chris Allegretta committed
649
650
@end table

David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
651

652
@node Nanorc Files
653
654
@chapter Nanorc Files

655
The nanorc files contain the default settings for @command{nano}.  They
656
should be in Unix format, not in DOS or Mac format.  During startup,
657
@command{nano} will first read the system-wide settings, from /etc/nanorc
658
(the exact path might be different), and then the user-specific settings,
659
660
either from @file{~/.nanorc} or from @file{$XDG_CONFIG_HOME/nano/nanorc}
or from @file{.config/nano/nanorc}, whichever exists first.
661
662

A nanorc file accepts a series of "set" and "unset" commands, which can
663
be used to configure @command{nano} on startup without using command-line
664
options.  Additionally, there are some commands to define syntax highlighting
665
and to rebind keys --- @pxref{Syntax Highlighting} and @ref{Rebinding Keys}.
666
@command{nano} will read one command per line.
667

668
Options in nanorc files take precedence over @command{nano}'s defaults, and
669
670
671
command-line options override nanorc settings.  Also, options that do not
take an argument are unset by default.  So using the @code{unset} command
is only needed when wanting to override a setting of the system's nanorc
672
file in your own nanorc.  Options that take an argument cannot be unset.
673
674
675

Quotes inside string parameters don't have to be escaped with
backslashes.  The last double quote in the string will be treated as its
676
end.  For example, for the @code{brackets} option, @t{""')>]@}"} will match
677
@code{"}, @code{'}, @code{)}, @code{>}, @code{]}, and @code{@}}.
678

679
680
681
682
683
@menu
* Settings::
* Syntax Highlighting::
* Rebinding Keys::
@end menu
684

685
686
@node Settings
@section Settings
687

688
The supported settings in a nanorc file are:
689
690
691

@table @code

692
@item set allow_insecure_backup
693
694
695
696
When backing up files, allow the backup to succeed even if its
permissions can't be (re)set due to special OS considerations.
You should NOT enable this option unless you are sure you need it.

697
698
699
700
@item set atblanks
When soft line wrapping is enabled, make it wrap lines at blank characters
(tabs and spaces) instead of always at the edge of the screen.

701
@item set autoindent
702
703
Use auto-indentation.

704
@item set backup
705
When saving a file, back up the previous version of it, using the current
706
filename suffixed with a tilde (@code{~}).
707

708
@item set backupdir "@var{directory}"
709
710
Make and keep not just one backup file, but make and keep a uniquely
numbered one every time a file is saved --- when backups are enabled
711
with @code{set backup} or @option{--backup} or @option{-B}.
712
The uniquely numbered files are stored in the specified directory.
713

714
@item set backwards
715
716
Obsolete option.  Recognized but ignored.  @code{^Q} is available to
start a backward search.
717

718
@item set boldtext
719
Use bold instead of reverse video for the title bar, status bar, key combos,
720
721
722
function tags, line numbers, and selected text.  This can be overridden by
setting the options @code{titlecolor}, @code{statuscolor}, @code{keycolor},
@code{functioncolor}, @code{numbercolor}, and @code{selectedcolor}.
723

724
@item set brackets "@var{string}"
725
Set the characters treated as closing brackets when justifying
726
paragraphs.  This may not include blank characters.  Only closing
727
punctuation (see @code{set punct}), optionally followed by the specified
728
closing brackets, can end sentences.  The default value is
729
@t{"')>]@}"}.
730

731
@item set casesensitive
732
Do case-sensitive searches by default.
733

734
@item set constantshow
735
Constantly display the cursor position on the status bar.
736
Note that this overrides @option{quickblank}.
737

738
739
740
@item set cutfromcursor
Use cut-from-cursor-to-end-of-line by default, instead of cutting the whole line.
(The old form of this option, @code{set cut}, is deprecated.)
741

742
743
744
745
@item set errorcolor @var{fgcolor},@var{bgcolor}
Use this color combination for the status bar when an error message is displayed.
@xref{@code{set functioncolor}} for valid color names.

746
747
748
@item set fill @var{number}
Hard-wrap lines at column number @var{number}.  If @var{number} is 0 or less,
the maximum line length will be the screen width less @var{number} columns.
749
750
The default value is @t{-8}.  This option conflicts with
@option{nowrap}; the last one given takes effect.
751

752
@anchor{@code{set functioncolor}}
753
@item set functioncolor @var{fgcolor},@var{bgcolor}
754
Use this color combination for the concise function descriptions
755
in the two help lines at the bottom of the screen.
756
757
Valid names for foreground and background color are:
@code{white}, @code{black}, @code{blue}, @code{green},
758
759
@code{red}, @code{cyan}, @code{yellow}, @code{magenta}, and @code{normal}
--- where @code{normal} means the default foreground or background color.
760
The name of the foreground color may be prefixed with @code{bright}.
761
And either @var{fgcolor} or ,@var{bgcolor} may be left out.
762

763
@item set historylog
764
765
Save the last hundred search strings and replacement strings and
executed commands, so they can be easily reused in later sessions.
766

767
@item set keycolor @var{fgcolor},@var{bgcolor}
768
Use this color combination for the shortcut key combos
769
in the two help lines at the bottom of the screen.
770
@xref{@code{set functioncolor}} for valid color names.
771

772
773
774
@item set linenumbers
Display line numbers to the left of the text area.

775
@item set locking
776
777
Enable vim-style lock-files for when editing files.

778
@item set matchbrackets "@var{string}"
779
Set the opening and closing brackets that can be found by bracket
780
781
searches.  This may not include blank characters.  The opening set must
come before the closing set, and the two sets must be in the same order.
782
The default value is @t{"(<[@{)>]@}"}.
783

784
@item set morespace
785
Use the blank line below the title bar as extra editing space.
786

787
@item set mouse
788
789
Enable mouse support, so that mouse clicks can be used to place the
cursor, set the mark (with a double click), or execute shortcuts.
790

791
@item set multibuffer
792
When reading in a file with @kbd{^R}, insert it into a new buffer by default.
793

794
@item set noconvert
795
796
Don't convert files from DOS/Mac format.

797
@item set nohelp
798
799
Don't display the help lists at the bottom of the screen.

800
801
802
803
@item set nopauses
Don't pause between warnings at startup.  This means that only
the last one will be visible (when there are multiple ones).

804
@item set nonewlines
805
806
Don't add newlines to the ends of files.

807
@item set nowrap
808
809
Don't hard-wrap text at all.  This option conflicts with
@option{fill}; the last one given takes effect.
810

811
@item set numbercolor @var{fgcolor},@var{bgcolor}
812
Use this color combination for line numbers.
813
@xref{@code{set functioncolor}} for valid color names.
814

815
@item set operatingdir "@var{directory}"
816
@command{nano} will only read and write files inside "directory" and its
817
subdirectories.  Also, the current directory is changed to here, so
818
files are inserted from this directory.  By default, the operating
819
820
directory feature is turned off.

821
@item set positionlog
822
Save the cursor position of files between editing sessions.
823
The cursor position is remembered for the 200 most-recently edited files.
824

825
@item set preserve
826
Preserve the XON and XOFF keys (@kbd{^Q} and @kbd{^S}).
827

828
@item set punct "@var{string}"
829
Set the characters treated as closing punctuation when justifying
830
831
paragraphs.  This may not include blank characters.  Only the
specified closing punctuation, optionally followed by closing brackets
832
833
(see @code{set brackets}), can end sentences.
The default value is @t{"!.?"}.
834

835
@item set quickblank
836
Do quick status-bar blanking: status-bar messages will disappear after 1
837
keystroke instead of 25.  Note that @option{constantshow} overrides this.
838

839
@item set quiet
840
Obsolete option.  Recognized but ignored.
841

842
@item set quotestr "@var{string}"
843
844
845
The email-quote string, used to justify email-quoted paragraphs.  This
is an extended regular expression if your system supports them,
otherwise a literal string.  The default value is
846
847
848
@t{"^([ \\t]*[#:>\\|@}])+"} if you have extended regular expression
support, and @t{"> "} otherwise.
Note that @code{\t} stands for a literal Tab character.
849

850
@item set rebinddelete
851
852
853
854
Interpret the Delete key differently so that both Backspace and Delete
work properly.  You should only need to use this option if Backspace
acts like Delete on your system.

855
@item set rebindkeypad
856
857
858
859
Interpret the numeric keypad keys so that they all work properly.  You
should only need to use this option if they don't, as mouse support
won't work properly with this option enabled.

860
@item set regexp
861
862
Do extended regular expression searches by default.

863
864
865
866
@item set selectedcolor @var{fgcolor},@var{bgcolor}
Use this color combination for selected text.
@xref{@code{set functioncolor}} for valid color names.

867
868
869
870
@item set showcursor
Put the cursor on the highlighted item in the file browser, to aid
braille users.

871
@item set smarthome
872
873
874
875
876
877
Make the Home key smarter.  When Home is pressed anywhere but at the
very beginning of non-whitespace characters on a line, the cursor will
jump to that beginning (either forwards or backwards).  If the cursor is
already at that position, it will jump to the true beginning of the
line.

878
@item set smooth
879
880
Use smooth scrolling by default.

881
@item set softwrap
882
Enable soft line wrapping for easier viewing of very long lines.
883

884
885
@item set speller "@var{program}"
Use the given program to do spell checking and correcting.
886
@xref{@option{--speller}} for details.
887

888
@item set statuscolor @var{fgcolor},@var{bgcolor}
889
Use this color combination for the status bar.
890
@xref{@code{set functioncolor}} for valid color names.
891

892
@item set suspend
893
Allow @command{nano} to be suspended.
894

895
896
@item set tabsize @var{number}
Use a tab size of @var{number} columns.  The value of @var{number} must be
897
greater than 0.  The default value is @t{8}.
898

899
@item set tabstospaces
900
901
Convert typed tabs to spaces.

902
@item set tempfile
903
904
Save automatically on exit, don't prompt.

905
@item set titlecolor @var{fgcolor},@var{bgcolor}
906
Use this color combination for the title bar.
907
@xref{@code{set functioncolor}} for valid color names.
908

909
910
911
912
@item set trimblanks
Remove trailing whitespace from wrapped lines when automatic
hard-wrapping occurs or when text is justified.

913
914
915
916
917
@item set unix
Save a file by default in Unix format.  This overrides nano's
default behavior of saving a file in the format that it had.
(This option has no effect when you also use @code{set noconvert}.)

918
@item set view
919
920
Disallow file modification.

921
@anchor{Whitespace}
922
@item set whitespace "@var{string}"
923
Set the two characters used to indicate the presence of tabs and
924
spaces.  They must be single-column characters.  The default pair
925
for a UTF-8 locale is @t{"»·"}, and for other locales @t{">."}.
926

927
@item set wordbounds
928
Detect word boundaries differently by treating punctuation
929
930
characters as part of a word.

931
932
933
934
935
@item set wordchars "@var{string}"
Specify which other characters (besides the normal alphanumeric ones)
should be considered as parts of words.  This overrides the option
@code{wordbounds}.

936
937
938
939
940
@end table

@node Syntax Highlighting
@section Syntax Highlighting

941
942
943
944
945
Coloring the different syntactic elements of a file
is done via regular expressions (see the @code{color} command below).
This is inherently imperfect, because regular expressions are not
powerful enough to fully parse a file.  Nevertheless, regular
expressions can do a lot and are easy to make, so they are a
946
good fit for a small editor like @command{nano}.
947
948

A separate syntax can be defined for each kind of file
949
950
951
952
via the following commands in a nanorc file:

@table @code

953
@item syntax "@var{name}" ["@var{fileregex}" @dots{}]
954
955
956
Start the definition of a syntax with this @var{name}.
All subsequent @code{color} and other such commands
will be added to this syntax, until a new @code{syntax}
957
command is encountered.
958

959
960
961
962
963
964
965
966
967
968
When @command{nano} is run, this syntax will be automatically
activated if the current filename matches the extended regular
expression @var{fileregex}.  Or the syntax can be explicitly
activated by using the @option{-Y} or @option{--syntax}
command-line option followed by the @var{name}.

The @code{default} syntax is special: it takes no @var{fileregex},
and applies to files that don't match any syntax's @var{fileregex}.
The @code{none} syntax is reserved; specifying it on the
command line is the same as not having a syntax at all.
969

970
971
972
973
974
975
976
977
978
979
980
981
982
@item header "@var{regex}" @dots{}
If from all defined syntaxes no @var{fileregex} matched, then compare
this @var{regex} (or regexes) against the first line of the current file,
to determine whether this syntax should be used for it.

@item magic "@var{regex}" @dots{}
If no @var{fileregex} matched and no @code{header} regex matched
either, then compare this @var{regex} (or regexes) against the
result of querying the @code{magic} database about the current
file, to determine whether this syntax should be used for it.
(This functionality only works when @code{libmagic} is installed
on the system and will be silently ignored otherwise.)

983
@item linter @var{program} [@var{arg} @dots{}]
984
985
Use the given @var{program} to do a syntax check on the current file.
(This overrides the speller function.)
986

987
@item formatter @var{program} [@var{arg} @dots{}]
988
989
990
Use the given @var{program} to automatically reformat text ---
useful for a programming language like Go.
(This overrides the speller and linter functions.)
991

992
@item comment "@var{string}"
993
994
995
Use the given string for commenting and uncommenting lines.
If the string contains a vertical bar or pipe character (@t{|}),
this designates bracket-style comments; for example, @t{"/*|*/"} for
996
997
CSS files.  The characters before the pipe are prepended to the line and the
characters after the pipe are appended at the end of the line.  If no pipe
998
character is present, the full string is prepended; for example, @t{"#"} for
999
Python files.  If empty double quotes are specified, the comment/uncomment
1000
functions are disabled; for example, @t{""} for JSON.
1001
The default value is @t{"#"}.
1002

1003
@item color @var{fgcolor},@var{bgcolor} "@var{regex}" @dots{}
1004
Display all pieces of text that match the
1005
1006
extended regular expression "regex" with foreground color "fgcolor" and
background color "bgcolor", at least one of which must be specified.
1007
Valid colors for foreground and background are: white, black, red,
1008
blue, green, yellow, magenta, and cyan.  You may use the prefix "bright"
1009
to get a stronger color highlight for the foreground.  If your
1010
terminal supports transparency, not specifying a "bgcolor" tells @command{nano}
1011
1012
to attempt to use a transparent background.

1013
@item icolor @var{fgcolor},@var{bgcolor} "@var{regex}" @dots{}
1014
Same as above, except that the matching is case insensitive.
1015

1016
@item color @var{fgcolor},@var{bgcolor} start="@var{fromrx}" end="@var{torx}"
1017
Display all pieces of text whose start matches extended regular expression
1018
1019
1020
1021
"fromrx" and whose end matches extended regular expression "torx" with
foreground color "fgcolor" and background color "bgcolor", at least one of
which must be specified.  This means that, after an initial instance of
"fromrx", all text until the first instance of "torx" will be colored.
1022
This allows syntax highlighting to span multiple lines.
1023

1024
@item icolor @var{fgcolor},@var{bgcolor} start="@var{fromrx}" end="@var{torx}"
1025
Same as above, except that the matching is case insensitive.
1026

1027
@item include "@var{syntaxfile}"
1028
Read in self-contained color syntaxes from "syntaxfile".  Note that
1029
1030
"syntaxfile" may contain only the above commands, from @code{syntax}
to @code{icolor}.
1031

1032
1033
@item extendsyntax @var{name} @var{command} [@var{arg} @dots{}]
Extend the syntax previously defined as "@var{name}" with another @var{command}.
1034
This allows you to add a new @code{color}, @code{icolor}, @code{header},
1035
1036
@code{magic}, @code{comment}, @code{linter}, or @code{formatter} command
to an already
1037
defined syntax --- useful when you want to slightly improve a syntax defined
1038
in one of the system-installed files (which normally are not writable).
1039

1040
1041
@end table

1042
1043
1044
@node Rebinding Keys
@section Rebinding Keys

1045
Key bindings can be changed via the following three commands in a
1046
1047
1048
1049
1050
1051
nanorc file:

@table @code

@item bind key function menu
Rebinds @code{key} to @code{function} in the context of @code{menu}
1052
(or in all menus where the function exists by using @code{all}).
1053

1054
1055
1056
1057
1058
1059
1060
@item bind key "string" menu
Makes @code{key} produce @code{string} in the context of @code{menu}
(or in all menus where the key exists when @code{all} is used).
The @code{string} can consist of text or commands or a mix of them.
(To enter a command into the @code{string}, precede its keystroke
with @kbd{M-V}.)

1061
@item unbind key menu
1062
Unbinds @code{key} from @code{menu}
1063
1064
1065
1066
(or from all menus where it exists by using @code{all}).

@end table

1067
@sp 1
1068
1069
The format of @code{key} should be one of:

1070
1071
1072
1073
@itemize @w{}
@item
@code{^}@  followed by an ASCII character or the word "Space".
Example: @code{^C}.
1074

1075
1076
1077
@item
@code{M-}@  followed by a ASCII character or the word "Space".
Example: @code{M-C}.
1078

1079
1080
1081
1082
@item
@code{F}@  followed by a numeric value from 1 to 16.
Example: @code{F10}.
@end itemize
1083

1084
@sp 1
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
Valid names for the @code{function} to be bound are:

@table @code

@item help
Invokes the help viewer.

@item cancel
Cancels the current command.

@item exit
Exits from the program (or from the help viewer or the file browser).

@item writeout
1099
1100
1101
Writes the current buffer to disk, asking for a name.

@item savefile
1102
Writes the current file to disk without prompting.
1103
1104

@item insert
1105
1106
Inserts a file into the current buffer (at the current cursor position),
or into a new buffer when option @code{multibuffer} is set.
1107
1108

@item whereis
1109
1110
1111
1112
1113
Starts a forward search for text in the current buffer --- or for filenames
matching a string in the current list in the file browser.

@item wherewas
Starts a backward search for text in the current buffer.
1114
1115

@item searchagain
1116
1117
1118
1119
1120
1121
1122
Repeats the last search command without prompting.

@item findprevious
As @code{searchagain}, but always in the backward direction.

@item findnext
As @code{searchagain}, but always in the forward direction.
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139

@item replace
Interactively replaces text within the current buffer.

@item cut
Cuts and stores the current line (or the marked region).

@item copytext
Copies the current line (or the marked region) without deleting it.

@item uncut
Copies the currently stored text into the current buffer at the
current cursor position.

@item mark
Sets the mark at the current position, to start selecting text.

1140
1141
1142
1143
1144
1145
@item cutwordleft
Cuts from the cursor position to the beginning of the preceding word.

@item cutwordright
Cuts from the cursor position to the beginning of the next word.

1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
@item cutrestoffile
Cuts all text from the cursor position till the end of the buffer.

@item curpos
Shows the current cursor position: the line, column, and character positions.

@item wordcount
Counts the number of words, lines and characters in the current buffer.

@item speller
Invokes a spell-checking program (or a linting program, if the current
syntax highlighting defines one).

@item justify
Justifies the current paragraph.

@item fulljustify
Justifies the entire current buffer.

@item indent
Indents (shifts to the right) the currently marked text.

@item unindent
Unindents (shifts to the left) the currently marked text.

1171
1172
1173
1174
@item comment
Comments or uncomments the current line or marked lines, using the comment
style specified in the active syntax.

1175
1176
1177
1178
@item complete
Completes the fragment before the cursor to a full word found elsewhere
in the current buffer.

1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
@item left
Goes left one position (in the editor or browser).

@item right
Goes right one position (in the editor or browser).

@item up
Goes one line up (in the editor or browser).

@item down
Goes one line down (in the editor or browser).

@item scrollup
1192
1193
Scrolls the viewport up one row (meaning that the text slides down)
while keeping the cursor in the same text position, if possible.
1194
1195

@item scrolldown
1196
1197
Scrolls the viewport down one row (meaning that the text slides up)
while keeping the cursor in the same text position, if possible.
1198
1199
1200
1201

@item prevword
Moves the cursor to the beginning of the previous word.

1202
1203
1204
@item nextword
Moves the cursor to the beginning of the next word.

1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
@item home
Moves the cursor to the beginning of the current line.

@item end
Moves the cursor to the end of the current line.

@item beginpara
Moves the cursor to the beginning of the current paragraph.

@item endpara
Moves the cursor to the end of the current paragraph.

1217
1218
1219
1220
1221
1222
1223
@item prevblock
Moves the cursor to the beginning of the current or preceding block of text.
(Blocks are separated by one or more blank lines.)

@item nextblock
Moves the cursor to the beginning of the next block of text.

1224
@item pageup
1225
1226
Goes up one screenful.

1227
@item pagedown
1228
1229
1230
1231
1232
1233
1234
1235
1236
Goes down one screenful.

@item firstline
Goes to the first line of the file.

@item lastline
Goes to the last line of the file.

@item gotoline
1237
1238
Goes to a specific line (and column if specified).  Negative numbers count
from the end of the file (and end of the line).
1239
1240
1241
1242
1243
1244

@item findbracket
Moves the cursor to the bracket (brace, parenthesis, etc.) that matches
(pairs) with the one under the cursor.

@item prevbuf
1245
Switches to editing/viewing the previous buffer when multiple buffers are open.
1246
1247

@item nextbuf
1248
Switches to editing/viewing the next buffer when multiple buffers are open.
1249
1250

@item verbatim
1251
Inserts the next keystroke verbatim into the file.
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264

@item tab
Inserts a tab at the current cursor location.

@item enter
Inserts a new line below the current one.

@item delete
Deletes the character under the cursor.

@item backspace
Deletes the character before the cursor.

1265
1266
1267
1268
1269
1270
1271
@item recordmacro
Starts the recording of keystrokes --- the keystrokes are stored
as a macro.  When already recording, the recording is stopped.

@item runmacro
Replays the keystrokes of the last recorded macro.

1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
@item undo
Undoes the last performed text action (add text, delete text, etc).

@item redo
Redoes the last undone action (i.e., it undoes an undo).

@item refresh
Refreshes the screen.

@item suspend
Suspends the editor (if the suspending function is enabled, see the
"suspendenable" entry below).

@item casesens
Toggles case sensitivity in searching (search/replace menus only).

@item regexp
Toggles whether searching/replacing is based on literal strings or regular expressions.

@item backwards
Toggles whether searching/replacing goes forward or backward.

@item prevhistory
1295
Shows the previous history entry in the prompt menus (e.g.@: search).
1296
1297

@item nexthistory
1298
Shows the next history entry in the prompt menus (e.g.@: search).
1299

1300
1301
@item flipreplace
Toggles between searching for something and replacing something.
1302

1303
1304
1305
1306
@item flipgoto
Toggles between searching for text and targeting a line number.
(The form @code{gototext} is deprecated.)

1307
1308
1309
@item flipexecute
Toggles between inserting a file and executing a command.

1310
1311
1312
@item flipnewbuffer
Toggles between inserting into the current buffer and into a new
empty buffer.
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328

@item dosformat
When writing a file, switches to writing a DOS format (CR/LF).

@item macformat
When writing a file, switches to writing a Mac format.

@item append
When writing a file, appends to the end instead of overwriting.

@item prepend
When writing a file, 'prepends' (writes at the beginning) instead of overwriting.

@item backup
When writing a file, creates a backup of the current file.

1329
1330
1331
1332
1333
@item discardbuffer
When about to write a file, discard the current buffer without saving.
(This function is bound by default only when option @option{--tempfile}
is in effect.)

1334
@item browser
1335
1336
1337
1338
1339
1340
Starts the file browser, allowing to select a file from a list.

@item gotodir
Goes to a directory to be specified, allowing to browse anywhere
in the filesystem.

1341
1342
1343
1344
1345
1346
1347
1348
1349
@item firstfile
Goes to the first file when using the file browser (reading or writing files).

@item lastfile
Goes to the last file when using the file browser (reading or writing files).

@item nohelp
Toggles the presence of the two-line list of key bindings at the bottom of the screen.

1350
@item constantshow
1351
1352
1353
Toggles the constant display of the current line, column, and character positions.

@item morespace
1354
Toggles the presence of the blank line that 'separates' the title bar from the file text.
1355
1356
1357
1358
1359
1360
1361

@item smoothscroll
Toggles smooth scrolling (when moving around with the arrow keys).

@item softwrap
Toggles the displaying of overlong lines on multiple screen lines.

1362
1363
1364
@item linenumbers
Toggles the display of line numbers in front of the text.

1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
@item whitespacedisplay
Toggles the showing of whitespace.

@item nosyntax
Toggles syntax highlighting.

@item smarthome
Toggles the smartness of the Home key.

@item autoindent
Toggles whether new lines will contain the same amount of whitespace as the preceding line.

1377
@item cutfromcursor
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
Toggles whether cutting text will cut the whole line or just from the current cursor
position to the end of the line.

@item nowrap
Toggles whether long lines will be hard-wrapped to the next line.

@item tabstospaces
Toggles whether typed tabs will be converted to spaces.

@item backupfile
Toggles whether a backup will be made of the file to be edited.

@item multibuffer
1391
1392
Toggles whether a file is inserted into the current buffer
or read into a new buffer.
1393
1394
1395
1396
1397
1398
1399
1400

@item mouse
Toggles mouse support.

@item noconvert
Toggles automatic conversion of files from DOS/Mac format.

@item suspendenable
1401
Toggles whether the suspend shortcut (normally @kbd{^Z}) will suspend the editor.
1402
1403
1404

@end table

1405
@sp 1
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
Valid names for @code{menu} are:

@table @code

@item main
The main editor window where text is entered and edited.

@item search
The search menu (AKA whereis).

@item replace
The 'search to replace' menu.

@item replacewith
The 'replace with' menu, which comes up after 'search to replace'.

@item gotoline
The 'goto line (and column)' menu.

@item writeout
The 'write file' menu.

@item insert
The 'insert file' menu.

@item extcmd
The menu for inserting output from an external command, reached from the insert menu.

@item help
The help-viewer menu.

@item spell
The interactive spell checker Yes/no menu.

@item linter
The linter menu.

@item browser
The file browser for inserting or writing a file.

@item whereisfile
The 'search for a file' menu in the file browser.

@item gotodir
The 'go to directory' menu in the file browser.

@item all
1453
1454
1455
A special name that encompasses all menus.  For @code{bind} it means
all menus where the specified @code{function} exists; for @code{unbind}
it means all menus where the specified @code{key} exists.
1456

1457
1458
@end table

1459

1460
@node The File Browser
Chris Allegretta's avatar
Chris Allegretta committed
1461
1462
@chapter The File Browser

1463
When reading or writing files, pressing @kbd{^T} will invoke the file browser.
1464
1465
Here, one can navigate directories in a graphical manner in order to
find the desired file.
Chris Allegretta's avatar
Chris Allegretta committed
1466

1467
1468
Basic movement in the file browser is accomplished with the arrow keys,
page up, and page down.  More advanced movement is accomplished by
1469
1470
1471
searching via @kbd{^W} (or @kbd{w'} and changing directories via
@kbd{^_} (or @kbd{g}).  The behavior of the @kbd{Enter} key (or @kbd{s})
varies by what is currently selected.
1472
1473
If the currently selected object is a directory, the file browser will
enter and display the contents of the directory.  If the object is a
1474
file, this filename and path are copied to the status bar, and the file
1475
browser exits.
Chris Allegretta's avatar
Chris Allegretta committed
1476

1477
1478

@node Pico Compatibility
Chris Allegretta's avatar
Chris Allegretta committed
1479
1480
@chapter Pico Compatibility

1481
@command{nano} attempts to emulate Pico as closely as possible, but there
1482
are some differences between the editors:
Chris Allegretta's avatar
Chris Allegretta committed
1483
1484

@table @code
1485

1486
1487
@item Interactive Replace
Instead of allowing you to replace either just one occurrence of a search
1488
string or all of them, @command{nano}'s replace function is interactive: it
1489
1490
1491
1492
1493
will pause at each found search string and query whether to replace this
instance.  You can then choose Yes, or No (skip this one), or All (don't
ask any more), or Cancel (stop with replacing).

@item Search and Replace History
1494
When the option @option{-H} or @option{--historylog} is given (or set in
1495
the a nanorc file), text entered as search or replace strings is stored.
1496
These strings can be accessed with the up/down arrow keys, or you can
1497
type the first few characters and then use @kbd{Tab} to cycle through the
1498
1499
1500
matching strings.  A retrieved string can subsequently be edited.

@item Position History
1501
When the option @option{-P} or @option{--positionlog} is given (or set in
1502
a nanorc file), @command{nano} will store the position of the cursor
1503
1504
1505
when you close a file, and will place the cursor in that position
again when you later reopen the file.

1506
@item Current Cursor Position
1507
The output of the "Display Cursor Position" command (@kbd{^C}) displays
1508
1509
1510
1511
1512
1513
1514
1515
not only the current line and character position of the cursor,
but also (between the two) the current column position.

@item Spell Checking
In the internal spell checker misspelled words are sorted alphabetically
and trimmed for uniqueness, such that the words 'apple' and 'Apple' will
be prompted for correction separately.

1516
@item Writing Selected Text to Files
1517
1518
When using the Write-Out key (@kbd{^O}), text that has been selected using the
marking key (@kbd{^^}) can not just be written out to a new (or existing) file,
1519
1520
1521
it can also be appended or prepended to an existing file.

@item Reading Text from a Command
1522
When using the Read-File key (@kbd{^R}), @command{nano} can not just read a file,
1523
it can also read the output of a command to be run (@kbd{^X}).
1524

1525
1526
@item Reading from Working Directory
By default, Pico will read files from the user's home directory (when
1527
using @kbd{^R}), but it will write files to the current working directory
1528
(when using @kbd{^O}).  @command{nano} makes this symmetrical: always reading
1529
from and writing to the current working directory --- the directory
1530
that @command{nano} was started in.
1531

1532
@item File Browser
1533
1534
In the file browser, @command{nano} does not implement the Add, Copy,
Rename, and Delete commands that Pico provides.  In @command{nano} the
1535
browser is just a file browser, not a file manager.
1536
1537

@item Toggles
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
1538
1539
Many options which alter the functionality of the program can be
"toggled" on or off using Meta key sequences, meaning the program does
1540
not have to be restarted to turn a particular feature on or off.
1541
@xref{Feature Toggles} for a list of options that can be toggled.
1542
Or see the list at the end of the main internal help text (@kbd{^G}) instead.
1543

Chris Allegretta's avatar
Chris Allegretta committed
1544
1545
@end table

1546
1547

@node Building and Configure Options
Chris Allegretta's avatar
Chris Allegretta committed
1548
1549
@chapter Building and Configure Options

1550
Building @command{nano} from source is fairly straightforward if you are
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
1551
familiar with compiling programs with autoconf support:
Chris Allegretta's avatar
Chris Allegretta committed
1552

1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
@iftex
@sp 1
@end iftex
@example
  tar xvzf nano-x.y.z.tar.gz
  cd nano-x.y.z
  ./configure
  make
  make install
@end example
@iftex
@sp 1
@end iftex
Chris Allegretta's avatar
Chris Allegretta committed
1566

1567
The possible options to @code{./configure} are:
Chris Allegretta's avatar
Chris Allegretta committed
1568

1569
@table @code
1570

1571
@item --disable-browser
1572
Disable the mini file browser that can be called with @kbd{^T} when reading
1573
or writing files.
Chris Allegretta's avatar
Chris Allegretta committed
1574

1575
@item --disable-color
1576
Disable support for the syntax coloring of files.  This also eliminates
1577
the @option{-Y} command-line option, which chooses a specific syntax.
1578

1579
@item --disable-comment
1580
Disable the single-keystroke comment/uncomment function (@kbd{M-3}).
1581

1582
@item --disable-extra
1583
Disable the Easter egg: a crawl of major contributors.
1584

Chris Allegretta's avatar
Chris Allegretta committed
1585
@item --disable-help
1586
1587
1588
Disable the help function.  Doing this makes the binary much smaller,
but makes it difficult for new users to learn more than very basic
things about using the editor.
Chris Allegretta's avatar
Chris Allegretta committed
1589

1590
1591
1592
@item --disable-histories
Disable the code for the handling of the history files: the search and
replace strings that were used, and the cursor position at which each
1593
file was closed.  This also eliminates the @option{-H} and @option{-P}
1594
1595
command-line options, which switch on the logging of search/replace
strings and cursor positions.
1596

1597
1598
@item --disable-justify
Disable the justify and unjustify functions.
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
1599

1600
1601
@item --disable-libmagic
Disable the use of the library of magic-number tests (for determining
1602
the file type and thus which syntax to use for colouring --- often the
1603
1604
tests on filename extension and header line will be enough).

1605
@item --disable-linenumbers
1606
Disable the line-numbering function (@kbd{M-#}).  This also eliminates the
1607
@option{-l} command-line option, which turns line numbering on.
1608

David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
1609
@item --disable-mouse
1610
Disable all mouse functionality.  This also eliminates the @option{-m}
1611
1612
1613
1614
command-line option, which enables the mouse functionality.

@item --disable-multibuffer
Disable support for opening multiple files at a time and switching
1615
between them on the fly.  This also eliminates the @option{-F} command-line
1616
option, which causes a file to be read into a separate buffer by default.
1617

1618
1619
1620
1621
@item --disable-nanorc
Disable support for reading the nanorc files at startup.  With such
support, you can store custom settings in a system-wide and a per-user
nanorc file rather than having to pass command-line options to get
1622
the desired behavior.  @xref{Nanorc Files} for more info.
1623
1624
Disabling this also eliminates the @option{-I} command-line option,
which inhibits the reading of nanorc files.
1625

1626
@item --disable-operatingdir
1627
Disable setting the operating directory.  This also eliminates the @option{-o}
1628
command-line option, which sets the operating directory.
1629

1630
@item --disable-speller
1631
Disable use of the spell checker.  This also eliminates the @option{-s}
1632
command-line option, which allows specifying an alternate spell checker.
1633
1634

@item --disable-tabcomp
1635
1636
1637
Disable tab completion (when nano asks for a filename or a search string).

@item --disable-wordcomp
1638
Disable word completion (@kbd{^]}).
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
1639

1640
@item --disable-wrapping
1641
Disable all hard-wrapping of overlong lines.  This also eliminates the
1642
@option{-w} command-line option, which switches long-line wrapping off.
Chris Allegretta's avatar
Chris Allegretta committed
1643
1644

@item --enable-tiny
1645
1646
1647
This option implies all of the above.  It also disables some other
internals of the editor, like the marking code, the cut-to-end-of-line
code, and the function toggles.  By using the enabling
1648
counterpart of the above options together with @option{--enable-tiny},
1649
specific features can be switched back on --- but a few cannot.
1650
1651
1652

@item --enable-debug
Enable support for runtime debug output.  This can get pretty messy, so
1653
chances are you only want this feature when you're working on the nano source.
1654

1655
@item --disable-nls
1656
Disables Native Language support.  This will disable the use of any
1657
available GNU @command{nano} translations.
1658
1659

@item --disable-wrapping-as-root
1660
Disable hard-wrapping of overlong lines by default when @command{nano}
1661
is run as root.
1662

1663
1664
@item --enable-utf8
Enable support for reading and writing Unicode files.  This will require
1665
either a wide version of curses, or a UTF-8-enabled version of Slang.
1666

1667
@item --disable-utf8
1668
1669
1670
Disable support for reading and writing Unicode files.  Normally the
configure script auto-detects whether to enable UTF-8 support or not.
You can use this or the previous option to override that detection.
1671

1672
1673
1674
1675
@item --enable-altrcname=@var{name}
Use the file with the given @var{name} (in the user's home directory)
as nano's settings file, instead of the default @code{.nanorc}.

1676
@item --with-slang
1677
Compile @command{nano} against Slang instead of against ncurses or other
1678
curses libraries.
1679

Chris Allegretta's avatar
Chris Allegretta committed
1680
1681
@end table

1682
1683
1684
1685
@html
<hr>
@end html

Chris Allegretta's avatar
Chris Allegretta committed
1686
@contents
1687

Chris Allegretta's avatar
Chris Allegretta committed
1688
@bye