summaryrefslogtreecommitdiffstats
path: root/upstream/archlinux/man5/nanorc.5
blob: 672f6e1658d64d706a329ce9462399f907117a72 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
.\" Copyright (C) 2003-2011, 2013-2024 Free Software Foundation, Inc.
.\"
.\" This document is dual-licensed.  You may distribute and/or modify it
.\" under the terms of either of the following licenses:
.\"
.\" * 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 with this program.  If not, see
.\"   <https://www.gnu.org/licenses/>.
.\"
.\" * 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 along with this program.  If not, see
.\"   <https://www.gnu.org/licenses/>.
.\"
.TH NANORC 5 "version 8.0" "May 2024"

.SH NAME
nanorc \- GNU nano's configuration file

.SH DESCRIPTION
The \fInanorc\fP files contain the default settings for \fBnano\fP,
a small and friendly text editor.  During startup, if \fB\-\-rcfile\fR
is not given, \fBnano\fR will read two files: first the
system-wide settings, from \fI/etc/nanorc\fP (the exact path might be
different on your system), and then the user-specific settings, either
from \fI~/.nanorc\fR or from \fI$XDG_CONFIG_HOME/nano/nanorc\fR
or from \fI~/.config/nano/nanorc\fR, whichever is encountered first.
If \fB\-\-rcfile\fR is given, \fBnano\fR will read just the specified
settings file.

.SH NOTICE
Since version 8.0, to be newcomer friendly, \fB^F\fR starts a forward search,
\fB^B\fR starts a backward search, \fBM\-F\fR searches the next occurrence
forward, and \fBM\-B\fR searches the next occurrence backward.  If you want
those keystrokes to do what they did before version 8.0, add the following
lines at the end of your \fInanorc\fR file:
.sp
.RS 4
.B bind ^F forward main
.br
.B bind ^B back main
.br
.B bind M\-F formatter main
.br
.B bind M\-B linter main
.RE
.sp

.SH OPTIONS
The configuration file accepts a series of \fBset\fP and \fBunset\fP
commands, which can be used to configure nano on startup without using
command-line options.  Additionally, there are some commands to define
syntax highlighting and to rebind keys -- see the two separate sections
on those.  \fBnano\fP reads one command per line.
All commands and keywords should be written in lowercase.
.sp
Options in \fInanorc\fP files take precedence over nano's defaults, and
command-line options override \fInanorc\fP settings.  Also, options that
do not take an argument are unset by default.  So using the \fBunset\fR
command is only needed when wanting to override a setting of the system's
\fInanorc\fR file in your own \fInanorc\fR.  Options that take an
argument cannot be unset.
.sp
Quotes inside the \fIcharacters\fR  parameters below should not be escaped.
The last double quote on the line will be seen as the closing quote.
.sp
The supported commands and arguments are:
.TP 3
.B set afterends
Make Ctrl+Right and Ctrl+Delete stop at word ends instead of beginnings.
.TP
.B set allow_insecure_backup
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.
.TP
.B 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.
.TP
.B set autoindent
Automatically indent a newly created line to the same number of tabs
and/or spaces as the previous line (or as the next line if the previous
line is the beginning of a paragraph).
.TP
.B set backup
When saving a file, create a backup file by adding a tilde (\fB~\fP) to
the file's name.
.TP
.B set backupdir "\fIdirectory\fP"
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
with \fBset backup\fR or \fB\-\-backup\fR or \fB\-B\fR.
The uniquely numbered files are stored in the specified \fIdirectory\fR.
.TP
.B set boldtext
Use bold instead of reverse video for the title bar, status bar,
prompt bar, mini bar, key combos, function tags, line numbers,
and selected text.  This can be overridden by setting the options
\fBtitlecolor\fP, \fBstatuscolor\fP,
\fBpromptcolor\fP, \fBminicolor\fP, \fBkeycolor\fP, \fBfunctioncolor\fP,
\fBnumbercolor\fP, and/or \fBselectedcolor\fP.
.TP
.B set bookstyle
When justifying, treat any line that starts with whitespace as the
beginning of a paragraph (unless auto-indenting is on).
.TP
.BI "set brackets """ characters """
Set the characters treated as closing brackets when justifying
paragraphs.  This may not include blank characters.  Only closing
punctuation (see \fBset punct\fP), optionally followed by the specified
closing brackets, can end sentences.  The default value is "\fB\(dq')>]}\fR".
.TP
.B set breaklonglines
Automatically hard-wrap the current line when it becomes overlong.
.TP
.B set casesensitive
Do case-sensitive searches by default.
.TP
.B set constantshow
Constantly display the cursor position in the status bar.
This overrides the option \fBquickblank\fR.
.TP
.B set cutfromcursor
Use cut-from-cursor-to-end-of-line by default, instead of cutting the whole line.
.TP
.B set emptyline
Do not use the line below the title bar, leaving it entirely blank.
.TP
.B set errorcolor \fR[\fBbold,\fR][\fBitalic,\fR]\fIfgcolor\fB,\fIbgcolor\fR
Use this color combination for the status bar when an error message is displayed.
The default value is \fBbold,white,red\fR.
See \fBset titlecolor\fR for valid color names.
.TP
.B set fill \fInumber\fR
Set the target width for justifying and automatic hard-wrapping at this
\fInumber\fR of columns.  If the value is 0 or less, wrapping will occur
at the width of the screen minus \fInumber\fR columns, allowing the wrap
point to vary along with the width of the screen if the screen is resized.
The default value is \fB\-8\fR.
.TP
.B set functioncolor \fR[\fBbold,\fR][\fBitalic,\fR]\fIfgcolor\fB,\fIbgcolor\fR
Use this color combination for the concise function descriptions
in the two help lines at the bottom of the screen.
See \fBset titlecolor\fR for more details.
.TP
.B set guidestripe \fInumber
Draw a vertical stripe at the given column, to help judge the width of the
text.  (The color of the stripe can be changed with \fBset stripecolor\fR.)
.TP
.B set historylog
Save the last hundred search strings and replacement strings and
executed commands, so they can be easily reused in later sessions.
.TP
.B set indicator
Display a "scrollbar" on the righthand side of the edit window.
It shows the position of the viewport in the buffer
and how much of the buffer is covered by the viewport.
.TP
.B set jumpyscrolling
Scroll the buffer contents per half-screen instead of per line.
.TP
.B set keycolor \fR[\fBbold,\fR][\fBitalic,\fR]\fIfgcolor\fB,\fIbgcolor\fR
Use this color combination for the shortcut key combos
in the two help lines at the bottom of the screen.
See \fBset titlecolor\fR for more details.
.TP
.B set linenumbers
Display line numbers to the left of the text area.
(Any line with an anchor additionally gets a mark in the margin.)
.TP
.B set locking
Enable vim-style lock-files for when editing files.
.TP
.B set magic
When neither the file's name nor its first line give a clue,
try using libmagic to determine the applicable syntax.
(Calling libmagic can be relatively time consuming.
It is therefore not done by default.)
.TP
.BI "set matchbrackets """ characters """
Specify the opening and closing brackets that can be found by bracket
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.
The default value is "\fB(<[{)>]}\fP".
.TP
.B set minibar
Suppress the title bar and instead show information about
the current buffer at the bottom of the screen, in the space
for the status bar.  In this "mini bar" the filename is shown
on the left, followed by an asterisk if the buffer has been modified.
On the right are displayed the current line and column number, the
code of the character under the cursor (in Unicode format: U+xxxx),
the same flags as are shown by \fBset stateflags\fR, and a percentage
that expresses how far the cursor is into the file (linewise).
When a file is loaded or saved, and also when switching between buffers,
the number of lines in the buffer is displayed after the filename.
This number is cleared upon the next keystroke, or replaced with an
[i/n] counter when multiple buffers are open.
The line plus column numbers and the character code are displayed only when
\fBset constantshow\fR is used, and can be toggled on and off with \fBM\-C\fR.
The state flags are displayed only when \fBset stateflags\fR is used.
.TP
.B set minicolor \fR[\fBbold,\fR][\fBitalic,\fR]\fIfgcolor\fB,\fIbgcolor\fR
Use this color combination for the mini bar.
(When this option is not specified, the colors of the title bar are used.)
See \fBset titlecolor\fR for more details.
.TP
.B set mouse
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
System, and on the console when gpm is running.  Text can still be
selected through dragging by holding down the Shift key.
.TP
.B set multibuffer
When reading in a file with \fB^R\fR, insert it into a new buffer by default.
.TP
.B set noconvert
Don't convert files from DOS/Mac format.
.TP
.B set nohelp
Don't display the two help lines at the bottom of the screen.
.TP
.B set nonewlines
Don't automatically add a newline when a text does not end with one.
(This can cause you to save non-POSIX text files.)
.TP
.B set nowrap
Deprecated option since it has become the default setting.
When needed, use \fBunset breaklonglines\fR instead.
.TP
.B set numbercolor \fR[\fBbold,\fR][\fBitalic,\fR]\fIfgcolor\fB,\fIbgcolor\fR
Use this color combination for line numbers.
See \fBset titlecolor\fR for more details.
.TP
.B set operatingdir "\fIdirectory\fP"
\fBnano\fP will only read and write files inside \fIdirectory\fP and its
subdirectories.  Also, the current directory is changed to here, so
files are inserted from this directory.  By default, the operating
directory feature is turned off.
.TP
.B set positionlog
Save the cursor position of files between editing sessions.
The cursor position is remembered for the 200 most-recently edited files.
.TP
.B set preserve
Preserve the XON and XOFF keys (\fB^Q\fR and \fB^S\fR).
.TP
.B set promptcolor \fR[\fBbold,\fR][\fBitalic,\fR]\fIfgcolor\fB,\fIbgcolor\fR
Use this color combination for the prompt bar.
(When this option is not specified, the colors of the title bar are used.)
See \fBset titlecolor\fR for more details.
.TP
.BI "set punct """ characters """
Set the characters treated as closing punctuation when justifying
paragraphs.  This may not include blank characters.  Only the
specified closing punctuation, optionally followed by closing brackets
(see \fBbrackets\fP), can end sentences.  The default value is "\fB!.?\fP".
.TP
.B set quickblank
Make status-bar messages disappear after 1 keystroke instead of after 20.
Note that option \fBconstantshow\fR overrides this.
When option \fBminibar\fR or \fBzero\fR is in effect,
\fBquickblank\fR makes a message disappear after
0.8 seconds instead of after the default 1.5 seconds.
.TP
.BI "set quotestr """ regex """
Set the regular expression for matching the quoting part of a line.
The default value is "\fB^([\ \\t]*([!#%:;>|}]|//))+\fP".
(Note that \fB\\t\fR stands for an actual Tab character.)
This makes it possible to rejustify blocks of quoted text when composing
email, and to rewrap blocks of line comments when writing source code.
.TP
.B set rawsequences
Interpret escape sequences directly, instead of asking \fBncurses\fR
to translate them.  (If you need this option to get some keys to work
properly, it means that the terminfo terminal description that is used
does not fully match the actual behavior of your terminal.  This can
happen when you ssh into a BSD machine, for example.)
Using this option disables \fBnano\fR's mouse support.
.TP
.B set rebinddelete
Interpret the Delete and Backspace keys differently so that both Backspace
and Delete work properly.  You should only use this option when on your
system either Backspace acts like Delete or Delete acts like Backspace.
.TP
.B set regexp
Do regular-expression searches by default.
Regular expressions in \fBnano\fR are of the extended type (ERE).
.TP
.B set saveonexit
Save a changed buffer automatically on exit (\fB^X\fR); don't prompt.
.TP
.B set scrollercolor \fIfgcolor\fB,\fIbgcolor\fR
Use this color combination for the indicator alias "scrollbar".
See \fBset titlecolor\fR for more details.
.TP
.B set selectedcolor \fR[\fBbold,\fR][\fBitalic,\fR]\fIfgcolor\fB,\fIbgcolor\fR
Use this color combination for selected text.
See \fBset titlecolor\fR for more details.
.TP
.B set showcursor
Put the cursor on the highlighted item in the file browser, and show
the cursor in the help viewer, to aid braille users and people with
poor vision.
.TP
.B set smarthome
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.
.TP
.B set softwrap
Display lines that exceed the screen's width over multiple screen lines.
(You can make this soft-wrapping occur at whitespace instead of rudely at
the screen's edge, by using also \fBset atblanks\fR.)
.TP
.B set speller """\fIprogram\fR [\fIargument \fR...]\fB"""
Use the given \fIprogram\fR to do spell checking and correcting, instead of
using the built-in corrector that calls \fBhunspell\fR(1) or \fBspell\fR(1).
.TP
.B set spotlightcolor \fR[\fBbold,\fR][\fBitalic,\fR]\fIfgcolor\fB,\fIbgcolor\fR
Use this color combination for highlighting a search match.
The default value is \fBblack,lightyellow\fR.
See \fBset titlecolor\fR for valid color names.
.TP
.B set stateflags
Use the top-right corner of the screen for showing some state flags:
\fBI\fR when auto-indenting, \fBM\fR when the mark is on, \fBL\fR when
hard-wrapping (breaking long lines), \fBR\fR when recording a macro,
and \fBS\fR when soft-wrapping.
When the buffer is modified, a star (\fB*\fR) is shown after the
filename in the center of the title bar.
.TP
.B set statuscolor \fR[\fBbold,\fR][\fBitalic,\fR]\fIfgcolor\fB,\fIbgcolor\fR
Use this color combination for the status bar.
See \fBset titlecolor\fR for more details.
.TP
.B set stripecolor \fR[\fBbold,\fR][\fBitalic,\fR]\fIfgcolor\fB,\fIbgcolor\fR
Use this color combination for the vertical guiding stripe.
See \fBset titlecolor\fR for more details.
.TP
.B set tabsize \fInumber\fR
Use a tab size of \fInumber\fR columns.  The value of \fInumber\fP must be
greater than 0.  The default value is \fB8\fR.
.TP
.B set tabstospaces
Convert each typed tab to spaces -- to the number of spaces
that a tab at that position would take up.
(Note: pasted tabs are not converted.)
.TP
.B set titlecolor \fR[\fBbold,\fR][\fBitalic,\fR]\fIfgcolor\fB,\fIbgcolor\fR
Use this color combination for the title bar.
Valid names for the foreground and background colors are:
.BR red ", " green ", " blue ", " magenta ", " yellow ", " cyan ", "
.BR white ", and " black .
Each of these eight names may be prefixed with the word \fBlight\fR
to get a brighter version of that color.
The word \fBgrey\fR or \fBgray\fR may be used
as a synonym for \fBlightblack\fR.
On a Linux console, \fBlight\fR does not have
any effect for a background color.
On terminal emulators that can do at least 256 colors,
other valid (but unprefixable) color names are:
.BR pink ", " purple ", " mauve ", " lagoon ", " mint ", "
.BR lime ", " peach ", " orange ", " latte ", "
.BR rosy ", " beet ", " plum ", " sea ", " sky ", " slate ", "
.BR teal ", " sage ", " brown ", " ocher ", " sand ", " tawny ", "
.BR brick ", " crimson ", and " normal
-- where \fBnormal\fR means the default foreground or background color.
On such emulators, the color may also be specified as a three-digit hexadecimal
number prefixed with \fB#\fR, with the digits representing the amounts of red,
green, and blue, respectively.  This tells \fBnano\fR to select from the
available palette the color that approximates the given values.

Either "\fIfgcolor\fR" or "\fB,\fIbgcolor\fR" may be left out,
and the pair may be preceded by \fBbold\fR and/or \fBitalic\fR
(separated by commas) to get a bold and/or slanting typeface,
if your terminal can do those.
.TP
.B set trimblanks
Remove trailing whitespace from wrapped lines when automatic
hard-wrapping occurs or when text is justified.
.TP
.B 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 \fBset noconvert\fR.)
.TP
.BI "set whitespace """ characters """
Set the two characters used to indicate the presence of tabs and
spaces.  They must be single-column characters.  The default pair
for a UTF-8 locale is "\fB\[Fc]\[md]\fR", and for other locales "\fB>.\fR".
.TP
.B set wordbounds
Detect word boundaries differently by treating punctuation
characters as parts of words.
.TP
.BI "set wordchars """ characters """
Specify which other characters (besides the normal alphanumeric ones)
should be considered as parts of words.  When using this option, you
probably want to unset \fBwordbounds\fR.
.TP
.B set zap
Let an unmodified Backspace or Delete erase the marked region
(instead of a single character, and without affecting the cutbuffer).
.TP
.B set zero
Hide all elements of the interface (title bar, status bar, and help lines)
and use all rows of the terminal for showing the contents of the buffer.
The status bar appears only when there is a significant message,
and disappears after 1.5 seconds or upon the next keystroke.
With \fBM\-Z\fR the title bar plus status bar can be toggled.
With \fBM\-X\fR the help lines.

.SH SYNTAX HIGHLIGHTING
Coloring the different syntactic elements of a file
is done via regular expressions (see the \fBcolor\fR 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
good fit for a small editor like \fBnano\fR.
.sp
All regular expressions in \fBnano\fR are POSIX extended regular expressions.
This means that \fB.\fR, \fB?\fR, \fB*\fR, \fB+\fR, \fB^\fR, \fB$\fR, and
several other characters are special.
The period \fB.\fR matches any single character,
\fB?\fR means the preceding item is optional,
\fB*\fR means the preceding item may be matched zero or more times,
\fB+\fR means the preceding item must be matched one or more times,
\fB^\fR matches the beginning of a line, and \fB$\fR the end,
\fB\\<\fR matches the start of a word, and \fB\\>\fR the end,
and \fB\\s\fR matches a blank.
It also means that lookahead and lookbehind are not possible.
A complete explanation can be found in the manual page of GNU grep:
\fBman grep\fR.
.sp
Each regular expression in a \fBnanorc\fR file should be wrapped in
double quotes (\fB""\fR).  Multiple regular expressions can follow
each other on a line by separating them with blanks.  This means that
a regular expression cannot contain a double quote followed by a blank.
When you need this combination inside a regular expression,
then either the double quote or the blank should be put
between square brackets (\fB[]\fR).
.sp
For each kind of file a separate syntax can be defined
via the following commands:
.TP
.BI syntax " name \fR[" """" fileregex """ " \fR...]
Start the definition of a syntax with this \fIname\fR.
All subsequent \fBcolor\fR and other such commands
will be added to this syntax, until a new \fBsyntax\fR
command is encountered.
.sp
When \fBnano\fR is run, this syntax will be automatically
activated (for the relevant buffer) if the absolute filename
matches the extended regular expression \fIfileregex\fR.
Or the syntax can be explicitly activated (for all buffers)
by using the \fB\-Y\fR or \fB\-\-syntax\fR
command-line option followed by the \fIname\fR.
.sp
The syntax \fBdefault\fP is special: it takes no \fIfileregex\fR,
and applies to files that don't match any syntax's regexes.
The syntax \fBnone\fP is reserved; specifying it on the command line
is the same as not having a syntax at all.
.TP
.BI "header """ regex """ \fR...
If from all defined syntaxes no \fIfileregex\fR matched, then compare
this \fIregex\fR (or regexes) against the first line of the current file,
to determine whether this syntax should be used for it.
.TP
.BI "magic """ regex """ \fR...
If no \fIfileregex\fR matched and no \fBheader\fR regex matched
either, then compare this \fIregex\fR (or regexes) against the
result of querying the \fBmagic\fP database about the current
file, to determine whether this syntax should be used for it.
(This functionality only works when \fBlibmagic\fP is installed on the
system and will be silently ignored otherwise.)
.TP
.BI formatter " program " \fR[ "argument " \fR...]
Run the given \fIprogram\fR on the full contents of the current buffer.
.TP
.BI linter " program " \fR[ "argument " \fR...]
Use the given \fIprogram\fR to run a syntax check on the current buffer.
.TP
.BI "comment """ string """
Use the given \fIstring\fR for commenting and uncommenting lines.
If the string contains a vertical bar or pipe character (\fB|\fR),
this designates bracket-style comments; for example, "\fB/*|*/\fR" for
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
character is present, the full string is prepended; for example, "\fB#\fR"
for Python files.  If empty double quotes are specified, the comment/uncomment
function is disabled; for example, "" for JSON.
The default value is "\fB#\fP".
.TP
.BI "tabgives """ string """
Make the <Tab> key produce the given \fIstring\fR.  Useful for languages like
Python that want to see only spaces for indentation.
This overrides the setting of the \fBtabstospaces\fR option.
.TP
.BI "color \fR[\fBbold,\fR][\fBitalic,\fR]" fgcolor , bgcolor " """ regex """ " \fR...
Paint all pieces of text that match the extended regular expression
\fIregex\fP with the given foreground and background colors, at least
one of which must be specified.  Valid color names are:
.BR red ", " green ", " blue ", " magenta ", " yellow ", " cyan ", "
.BR white ", and " black .
Each of these eight names may be prefixed with the word \fBlight\fR
to get a brighter version of that color.
The word \fBgrey\fR or \fBgray\fR may be used
as a synonym for \fBlightblack\fR.
On a Linux console, \fBlight\fR does not have
any effect for a background color.
On terminal emulators that can do at least 256 colors,
other valid (but unprefixable) color names are:
.BR pink ", " purple ", " mauve ", " lagoon ", " mint ", "
.BR lime ", " peach ", " orange ", " latte ", "
.BR rosy ", " beet ", " plum ", " sea ", " sky ", " slate ", "
.BR teal ", " sage ", " brown ", " ocher ", " sand ", " tawny ", "
.BR brick ", " crimson ", and " normal
-- where \fBnormal\fR means the default foreground or background color.
On such emulators, the color may also be specified as a three-digit hexadecimal
number prefixed with \fB#\fR, with the digits representing the amounts of red,
green, and blue, respectively.  This tells \fBnano\fR to select from the
available palette the color that approximates the given values.

The color pair may be preceded by \fBbold\fR and/or \fBitalic\fR
(separated by commas) to get a bold and/or slanting typeface,
if your terminal can do those.
.sp
All coloring commands are applied in the order in which they are specified,
which means that later commands can recolor stuff that was colored earlier.
.TP
.BI "icolor \fR[\fBbold,\fR][\fBitalic,\fR]" fgcolor , bgcolor " """ regex """ " \fR...
Same as above, except that the matching is case insensitive.
.TP
.BI "color \fR[\fBbold,\fR][\fBitalic,\fR]" fgcolor , bgcolor " start=""" fromrx """ end=""" torx """
Paint all pieces of text whose start matches extended regular expression
\fIfromrx\fP and whose end matches extended regular expression \fItorx\fP
with the given foreground and background colors,
at least one of which must be specified.  This means that, after an
initial instance of \fIfromrx\fP, all text until the first instance of
\fItorx\fP will be colored.  This allows syntax highlighting to span
multiple lines.
.TP
.BI "icolor \fR[\fBbold,\fR][\fBitalic,\fR]" fgcolor , bgcolor " start=""" fromrx """ end=""" torx """
Same as above, except that the matching is case insensitive.
.TP
.BI "include """ syntaxfile """
Read in self-contained color syntaxes from \fIsyntaxfile\fP.  Note that
\fIsyntaxfile\fP may contain only the above commands, from \fBsyntax\fP
to \fBicolor\fP.
.TP
.BI extendsyntax " name command argument " \fR...
Extend the syntax previously defined as \fIname\fR with another
\fIcommand\fR.  This allows adding a new \fBcolor\fP, \fBicolor\fP,
\fBheader\fR, \fBmagic\fR, \fBformatter\fR, \fBlinter\fR, \fBcomment\fR,
or \fBtabgives\fR
command to an already defined syntax -- useful when you want to
slightly improve a syntax defined in one of the system-installed
files (which normally are not writable).

.SH REBINDING KEYS
Key bindings can be changed via the following three commands:
.RS 3
.TP
.BI bind " key function menu"
Rebinds the given \fIkey\fP to the given \fIfunction\fP in the given \fImenu\fP
(or in all menus where the function exists when \fBall\fP is used).
.TP
.BI bind " key " """" string """" " menu"
Makes the given \fIkey\fR produce the given \fIstring\fR in the given
\fImenu\fR (or in all menus where the key exists when \fBall\fR is used).
Besides literal text and/or control codes, the \fIstring\fR may contain
function names between braces.  These functions will be invoked when
the key is typed.  To include a literal opening brace, use \fB{{}\fR.
.TP
.BI unbind " key menu"
Unbinds the given \fIkey\fP from the given \fImenu\fP (or from all
menus where the key exists when \fBall\fP is used).
.RE
.sp
Note that \fBbind \fIkey\fR \fB"{\fIfunction\fB}"\fR \fImenu\fR is equivalent
to \fBbind \fIkey\fR \fIfunction\fR \fImenu\fR, except that for the latter form
\fBnano\fR will check the availability of the \fIfunction\fR in the given \fImenu\fR
at startup time (and report an error if it does not exist there), whereas for the
first form \fBnano\fR will check at execution time that the \fIfunction\fR exists
but not whether it makes any sense in the current menu.  The user has to take care
that a function name between braces (or any sequence of them) is appropriate.
Strange behavior can result when it is not.

.TP
The format of \fIkey\fP should be one of:
.RS 3
.TP 7
.BI ^ X
where \fIX\fR is a Latin letter, or one of several ASCII characters
(@, ], \\, ^, _), or the word "Space".
Example: ^C.
.TP
.BI M\- X
where \fIX\fR is any ASCII character except [, or the word "Space".
Example: M\-8.
.TP
.BI Sh\-M\- X
where \fIX\fR is a Latin letter.
Example: Sh\-M\-U.
By default, each Meta+letter keystroke does the same as the corresponding
Shift+Meta+letter.  But when any Shift+Meta bind is made, that will
no longer be the case, for all letters.
.TP
.BI F N
where \fIN\fR is a numeric value from 1 to 24.
Example: F10.
(Often, \fBF13\fR to \fBF24\fR can be typed as \fBF1\fR to \fBF12\fR with Shift.)
.TP
.BR Ins " or " Del .
.RE
.sp
Rebinding \fB^M\fR (Enter) or \fB^I\fR (Tab) is probably not a good idea.
Rebinding \fB^[\fR (Esc) is not possible, because its keycode
is the starter byte of Meta keystrokes and escape sequences.
Rebinding any of the dedicated cursor-moving keys (the arrows, Home, End,
PageUp and PageDown) is not possible.
On some terminals it's not possible to rebind \fB^H\fR (unless \fB\-\-raw\fR
is used) because its keycode is identical to that of the Backspace key.

.TP
Valid \fIfunction\fP names to be bound are:
.RS 3
.TP 2
.B help
Invokes the help viewer.
.TP
.B cancel
Cancels the current command.
.TP
.B exit
Exits from the program (or from the help viewer or file browser).
.TP
.B writeout
Writes the current buffer to disk, asking for a name.
.TP
.B savefile
Writes the current file to disk without prompting.
.TP
.B insert
Inserts a file into the current buffer (at the current cursor position),
or into a new buffer when option \fBmultibuffer\fR is set.
.TP
.B whereis
Starts a forward search for text in the current buffer -- or for filenames
matching a string in the current list in the file browser.
.TP
.B wherewas
Starts a backward search for text in the current buffer -- or for filenames
matching a string in the current list in the file browser.
.TP
.B findprevious
Searches the next occurrence in the backward direction.
.TP
.B findnext
Searches the next occurrence in the forward direction.
.TP
.B replace
Interactively replaces text within the current buffer.
.TP
.B cut
Cuts and stores the current line (or the marked region).
.TP
.B copy
Copies the current line (or the marked region) without deleting it.
.TP
.B paste
Pastes the currently stored text into the current buffer at the
current cursor position.
.TP
.B zap
Throws away the current line (or the marked region).
(This function is bound by default to <Meta+Delete>.)
.TP
.B chopwordleft
Deletes from the cursor position to the beginning of the preceding word.
(This function is bound by default to <Shift+Ctrl+Delete>.  If your terminal
produces \fB^H\fR for <Ctrl+Backspace>, you can make <Ctrl+Backspace> delete
the word to the left of the cursor by rebinding \fB^H\fR to this function.)
.TP
.B chopwordright
Deletes from the cursor position to the beginning of the next word.
(This function is bound by default to <Ctrl+Delete>.)
.TP
.B cutrestoffile
Cuts all text from the cursor position till the end of the buffer.
.TP
.B mark
Sets the mark at the current position, to start selecting text.
Or, when it is set, unsets the mark.
.TP
.B location
Reports the current position of the cursor in the buffer:
the line, column, and character positions.
.TP
.B wordcount
Counts and reports on the status bar the number of lines, words,
and characters in the current buffer (or in the marked region).
.TP
.B execute
Prompts for a program to execute.  The program's output will be inserted
into the current buffer (or into a new buffer when \fBM\-F\fR is toggled).
.TP
.B speller
Invokes a spell-checking program, either the default \fBhunspell\fR(1) or GNU
\fBspell\fR(1), or the one defined by \fB\-\-speller\fR or \fBset speller\fR.
.TP
.B formatter
Invokes a full-buffer-processing program (if the active syntax defines one).
(The current buffer is written out to a temporary file, the program
is run on it, and then the temporary file is read back in, replacing
the contents of the buffer.)
.TP
.B linter
Invokes a syntax-checking program (if the active syntax defines one).
If this program produces lines of the form "filename:linenum:charnum:
some message", then the cursor will be put at the indicated position
in the mentioned file while showing "some message" on the status bar.
You can move from message to message with <PgUp> and <PgDn>,
and leave linting mode with \fB^C\fR or <Enter>.
.TP
.B justify
Justifies the current paragraph (or the marked region).
A paragraph is a group of contiguous lines that, apart from possibly
the first line, all have the same indentation.  The beginning of a
paragraph is detected by either this lone line with a differing
indentation or by a preceding blank line.
.TP
.B fulljustify
Justifies the entire current buffer (or the marked region).
.TP
.B indent
Indents (shifts to the right) the current line or the marked lines.
.TP
.B unindent
Unindents (shifts to the left) the current line or the marked lines.
.TP
.B comment
Comments or uncomments the current line or the marked lines,
using the comment style specified in the active syntax.
.TP
.B complete
Completes (when possible) the fragment before the cursor
to a full word found elsewhere in the current buffer.
.TP
.B left
Goes left one position (in the editor or browser).
.TP
.B right
Goes right one position (in the editor or browser).
.TP
.B up
Goes one line up (in the editor or browser).
.TP
.B down
Goes one line down (in the editor or browser).
.TP
.B scrollup
Scrolls the viewport up one row (meaning that the text slides down)
while keeping the cursor in the same text position, if possible.
(This function is bound by default to <Alt+Up>.
If <Alt+Up> does nothing on your Linux console, see the FAQ:
.UR https://nano\-editor.org/dist/latest/faq.html#4.1
.UE .)
.TP
.B scrolldown
Scrolls the viewport down one row (meaning that the text slides up)
while keeping the cursor in the same text position, if possible.
(This function is bound by default to <Alt+Down>.)
.TP
.B center
Scrolls the line with the cursor to the middle of the screen.
.TP
.B prevword
Moves the cursor to the beginning of the previous word.
.TP
.B nextword
Moves the cursor to the beginning of the next word.
.TP
.B home
Moves the cursor to the beginning of the current line.
.TP
.B end
Moves the cursor to the end of the current line.
.TP
.B beginpara
Moves the cursor to the beginning of the current paragraph.
.TP
.B endpara
Moves the cursor to the end of the current paragraph.
.TP
.B prevblock
Moves the cursor to the beginning of the current or preceding block of text.
(Blocks are separated by one or more blank lines.)
.TP
.B nextblock
Moves the cursor to the beginning of the next block of text.
.TP
.B toprow
Moves the cursor to the first row in the viewport.
.TP
.B bottomrow
Moves the cursor to the last row in the viewport.
.TP
.B pageup
Goes up one screenful.
.TP
.B pagedown
Goes down one screenful.
.TP
.B firstline
Goes to the first line of the file.
.TP
.B lastline
Goes to the last line of the file.
.TP
.B gotoline
Goes to a specific line (and column if specified).  Negative numbers count
from the end of the file (and end of the line).
.TP
.B findbracket
Moves the cursor to the bracket (or brace or parenthesis, etc.) that matches
(pairs) with the one under the cursor.  See \fBset matchbrackets\fR.
.TP
.B anchor
Places an anchor at the current line, or removes it when already present.
(An anchor is visible when line numbers are activated.)
.TP
.B prevanchor
Goes to the first anchor before the current line.
.TP
.B nextanchor
Goes to the first anchor after the current line.
.TP
.B prevbuf
Switches to editing/viewing the previous buffer when multiple buffers are open.
.TP
.B nextbuf
Switches to editing/viewing the next buffer when multiple buffers are open.
.TP
.B verbatim
Inserts the next keystroke verbatim into the file, or begins Unicode input
when a hexadecimal digit is typed.
.TP
.B tab
Inserts a tab at the current cursor location.
.TP
.B enter
Inserts a new line below the current one.
.TP
.B delete
Deletes the character under the cursor.
.TP
.B backspace
Deletes the character before the cursor.
.TP
.B recordmacro
Starts the recording of keystrokes -- the keystrokes are stored
as a macro.  When already recording, the recording is stopped.
.TP
.B runmacro
Replays the keystrokes of the last recorded macro.
.TP
.B undo
Undoes the last performed text action (add text, delete text, etc).
.TP
.B redo
Redoes the last undone action (i.e., it undoes an undo).
.TP
.B refresh
Refreshes the screen.
.TP
.B suspend
Suspends the editor and returns control to the shell
(until you tell the process to resume execution with \fBfg\fR).
.TP
.B casesens
Toggles whether searching/replacing ignores or respects the case of
the given characters.
.TP
.B regexp
Toggles whether searching/replacing uses literal strings or regular expressions.
.TP
.B backwards
Toggles whether searching/replacing goes forward or backward.
.TP
.B older
Retrieves the previous (earlier) entry at a prompt.
.TP
.B newer
Retrieves the next (later) entry at a prompt.
.TP
.B flipreplace
Toggles between searching for something and replacing something.
.TP
.B flipgoto
Toggles between searching for text and targeting a line number.
.TP
.B flipexecute
Switches from inserting a file to executing a command.
.TP
.B flippipe
When executing a command, toggles whether the current buffer (or marked
region) is piped to the command.
.TP
.B flipnewbuffer
Toggles between inserting into the current buffer and into a new
empty buffer.
.TP
.B flipconvert
When reading in a file, toggles between converting and not converting
it from DOS/Mac format.  Converting is the default.
.TP
.B dosformat
When writing a file, switches to writing a DOS format (CR/LF).
.TP
.B macformat
When writing a file, switches to writing a Mac format.
.TP
.B append
When writing a file, appends to the end instead of overwriting.
.TP
.B prepend
When writing a file, 'prepends' (writes at the beginning) instead of overwriting.
.TP
.B backup
When writing a file, creates a backup of the current file.
.TP
.B discardbuffer
When about to write a file, discard the current buffer without saving.
(This function is bound by default only when option \fB\-\-saveonexit\fR
is in effect.)
.TP
.B browser
Starts the file browser (in the Read File and Write Out menus),
allowing to select a file from a list.
.TP
.B gotodir
Goes to a directory to be specified, allowing to browse anywhere
in the filesystem.
.TP
.B firstfile
Goes to the first file in the list when using the file browser.
.TP
.B lastfile
Goes to the last file in the list when using the file browser.
.TP
.B nohelp
Toggles the presence of the two-line list of key bindings at the bottom of the screen.
(This toggle is special: it is available in all menus except the help viewer
and the linter.  All further toggles are available in the main menu only.)
.TP
.B zero
Toggles the presence of title bar and status bar.
.TP
.B constantshow
Toggles the constant display of the current line, column, and character positions.
.TP
.B softwrap
Toggles the displaying of overlong lines on multiple screen lines.
.TP
.B linenumbers
Toggles the display of line numbers in front of the text.
.TP
.B whitespacedisplay
Toggles the showing of whitespace.
.TP
.B nosyntax
Toggles syntax highlighting.
.TP
.B smarthome
Toggles the smartness of the Home key.
.TP
.B autoindent
Toggles whether a newly created line will contain the same amount of leading
whitespace as the preceding line -- or as the next line if the preceding line
is the beginning of a paragraph.
.TP
.B cutfromcursor
Toggles whether cutting text will cut the whole line or just from the current cursor
position to the end of the line.
.TP
.B breaklonglines
Toggles whether long lines will be hard-wrapped to the next line.
(The old name of this function, 'nowrap', is deprecated.)
.TP
.B tabstospaces
Toggles whether typed tabs will be converted to spaces.
.TP
.B mouse
Toggles mouse support.
.RE

.TP
Valid \fImenu\fP sections are:
.RS 3
.TP 2
.B main
The main editor window where text is entered and edited.
.TP
.B help
The help-viewer menu.
.TP
.B search
The search menu (AKA whereis).
.TP
.B replace
The 'search to replace' menu.
.TP
.B replacewith
The 'replace with' menu, which comes up after 'search to replace'.
.TP
.B yesno
The 'yesno' menu, where the Yes/No/All/Cancel question is asked.
.TP
.B gotoline
The 'goto line (and column)' menu.
.TP
.B writeout
The 'write file' menu.
.TP
.B insert
The 'insert file' menu.
.TP
.B browser
The 'file browser' menu, for selecting a file to be opened or
inserted or written to.
.TP
.B whereisfile
The 'search for a file' menu in the file browser.
.TP
.B gotodir
The 'go to directory' menu in the file browser.
.TP
.B execute
The menu for inserting the output from an external command,
or for filtering the buffer (or the marked region) through
an external command, or for executing one of several tools.
.TP
.B spell
The menu of the integrated spell checker where the user can edit a misspelled word.
.TP
.B linter
The linter menu, which allows jumping through the linting messages.
.TP
.B all
A special name that encompasses all menus.
For \fBbind\fR it means all menus where the specified \fIfunction\fR exists;
for \fBunbind\fR it means all menus where the specified \fIkey\fR exists.
.RE

.SH EXAMPLES
To make \fBCtrl+Z\fR suspend nano:
.sp
.RS
.B bind ^Z suspend main
.RE
.sp
To make \fBShift+Alt+C\fR copy the marked region to the system's clipboard:
.sp
.RS
.B bind Sh-M-C """{execute}| xsel -ib {enter}{undo}""" main
.RE
.sp

.SH FILES
.TP
.I /etc/nanorc
System-wide configuration file.
.TP
.IR ~/.nanorc " or " $XDG_CONFIG_HOME/nano/nanorc " or " ~/.config/nano/nanorc
Per-user configuration file.
.TP
.I /usr/share/nano/*
Syntax definitions for the syntax coloring of common file types
(and for less common file types in the \fIextra/\fR subdirectory).

.SH SEE ALSO
.BR nano (1)
.TP
.I https://nano-editor.org/cheatsheet.html
An overview of the default key bindings.