1NANORC(5) File Formats Manual NANORC(5)
2
3
4
6 nanorc - GNU nano's configuration file
7
8
10 The nanorc file contains the default settings for nano, a small and
11 friendly editor. The file should be in Unix format, not in DOS or Mac
12 format. During startup, nano will first read the system-wide settings,
13 from /etc/nanorc (the exact path might be different on your system),
14 and then the user-specific settings, either from ~/.nanorc or from
15 $XDG_CONFIG_HOME/nano/nanorc or from ~/.config/nano/nanorc, whichever
16 is encountered first.
17
18
20 The configuration file accepts a series of set and unset commands,
21 which can be used to configure nano on startup without using command-
22 line options. Additionally, there are some commands to define syntax
23 highlighting and to rebind keys -- see the two separate sections on
24 those. nano reads one command per line.
25
26 Options in nanorc files take precedence over nano's defaults, and com‐
27 mand-line options override nanorc settings. Also, options that do not
28 take an argument are unset by default. So using the unset command is
29 only needed when wanting to override a setting of the system's nanorc
30 file in your own nanorc. Options that take an argument cannot be
31 unset.
32
33 Below, the string parameters need to be enclosed in double quotes.
34 Quotes inside these string parameters don't have to be escaped with
35 backslashes. The last double quote in the string will be treated as
36 its end. For example, for the brackets option, ""')>]}" will match ",
37 ', ), >, ], and }.
38
39 The supported commands and arguments are:
40
41
42 set afterends
43 Make Ctrl+Right stop at word ends instead of beginnings.
44
45 set allow_insecure_backup
46 When backing up files, allow the backup to succeed even if its per‐
47 missions can't be (re)set due to special OS considerations. You
48 should NOT enable this option unless you are sure you need it.
49
50 set atblanks
51 When soft line wrapping is enabled, make it wrap lines at blank
52 characters (tabs and spaces) instead of always at the edge of the
53 screen.
54
55 set autoindent
56 Automatically indent a newly created line to the same number of tabs
57 and/or spaces as the previous line (or as the next line if the pre‐
58 vious line is the beginning of a paragraph).
59
60 set backup
61 When saving a file, create a backup file by adding a tilde (~) to
62 the file's name.
63
64 set backupdir directory
65 Make and keep not just one backup file, but make and keep a uniquely
66 numbered one every time a file is saved -- when backups are enabled
67 with set backup or --backup or -B. The uniquely numbered files are
68 stored in the specified directory.
69
70 set backwards
71 Obsolete option. Recognized but ignored. ^Q is available to start
72 a backward search.
73
74 set boldtext
75 Use bold instead of reverse video for the title bar, status bar, key
76 combos, function tags, line numbers, and selected text. This can be
77 overridden by setting the options titlecolor, statuscolor, keycolor,
78 functioncolor, numbercolor, and selectedcolor.
79
80 set brackets string
81 Set the characters treated as closing brackets when justifying para‐
82 graphs. This may not include blank characters. Only closing punc‐
83 tuation (see set punct), optionally followed by the specified clos‐
84 ing brackets, can end sentences. The default value is ""')>]}".
85
86 set casesensitive
87 Do case-sensitive searches by default.
88
89 set constantshow
90 Constantly display the cursor position in the status bar. This
91 overrides the option quickblank.
92
93 set cutfromcursor
94 Use cut-from-cursor-to-end-of-line by default, instead of cutting
95 the whole line. (The old form of this option, 'set cut', is depre‐
96 cated.)
97
98 set errorcolor fgcolor,bgcolor
99 Use this color combination for the status bar when an error message
100 is displayed. See set titlecolor for valid color names.
101
102 set fill number
103 Hard-wrap lines at column number number. If number is 0 or less,
104 the maximum line length will be the screen width less number col‐
105 umns. The default value is -8. This option conflicts with nowrap
106 -- the last one given takes effect.
107
108 set functioncolor fgcolor,bgcolor
109 Specify the color combination to use for the function descriptions
110 in the two help lines at the bottom of the screen. See set title‐
111 color for more details.
112
113 set historylog
114 Save the last hundred search strings and replacement strings and
115 executed commands, so they can be easily reused in later sessions.
116
117 set keycolor fgcolor,bgcolor
118 Specify the color combination to use for the shortcut key combos in
119 the two help lines at the bottom of the screen. See set titlecolor
120 for more details.
121
122 set linenumbers
123 Display line numbers to the left of the text area.
124
125 set locking
126 Enable vim-style lock-files for when editing files.
127
128 set matchbrackets string
129 Set the opening and closing brackets that can be found by bracket
130 searches. This may not include blank characters. The opening set
131 must come before the closing set, and the two sets must be in the
132 same order. The default value is "(<[{)>]}".
133
134 set morespace
135 Use the blank line below the title bar as extra editing space.
136
137 set mouse
138 Enable mouse support, if available for your system. When enabled,
139 mouse clicks can be used to place the cursor, set the mark (with a
140 double click), and execute shortcuts. The mouse will work in the X
141 Window System, and on the console when gpm is running. Text can
142 still be selected through dragging by holding down the Shift key.
143
144 set multibuffer
145 When reading in a file with ^R, insert it into a new buffer by
146 default.
147
148 set noconvert
149 Don't convert files from DOS/Mac format.
150
151 set nohelp
152 Don't display the two help lines at the bottom of the screen.
153
154 set nonewlines
155 When a file does not end with a newline, don't automatically add
156 one.
157
158 set nopauses
159 Don't pause between warnings at startup. This means that only the
160 last one will be visible (when there are multiple ones).
161
162 set nowrap
163 Don't hard-wrap text at all. This option conflicts with fill -- the
164 last one given takes effect.
165
166 set numbercolor fgcolor,bgcolor
167 Specify the color combination to use for line numbers. See set
168 titlecolor for more details.
169
170 set operatingdir directory
171 nano will only read and write files inside directory and its subdi‐
172 rectories. Also, the current directory is changed to here, so files
173 are inserted from this directory. By default, the operating direc‐
174 tory feature is turned off.
175
176 set positionlog
177 Save the cursor position of files between editing sessions. The
178 cursor position is remembered for the 200 most-recently edited
179 files.
180
181 set preserve
182 Preserve the XON and XOFF keys (^Q and ^S).
183
184 set punct string
185 Set the characters treated as closing punctuation when justifying
186 paragraphs. This may not include blank characters. Only the spec‐
187 fified closing punctuation, optionally followed by closing brackets
188 (see brackets), can end sentences. The default value is "!.?".
189
190 set quickblank
191 Do quick status-bar blanking: status-bar messages will disappear
192 after 1 keystroke instead of 25. The option constantshow overrides
193 this.
194
195 set quiet
196 Obsolete option. Recognized but ignored.
197
198 set quotestr regex
199 The email-quote string, used to justify email-quoted paragraphs.
200 This is an extended regular expression. The default value is
201 "^([ \t]*([#:>|}]|//))+". Note that \t stands for an actual Tab
202 character.
203
204 set rebinddelete
205 Interpret the Delete key differently so that both Backspace and
206 Delete work properly. You should only need to use this option if
207 Backspace acts like Delete on your system.
208
209 set rebindkeypad
210 Interpret the numeric keypad keys so that they all work properly.
211 You should only need to use this option if they don't, as mouse sup‐
212 port won't work properly with this option enabled.
213
214 set regexp
215 Do extended regular expression searches by default.
216
217 set selectedcolor fgcolor,bgcolor
218 Specify the color combination to use for selected text. See set
219 titlecolor for more details.
220
221 set showcursor
222 Put the cursor on the highlighted item in the file browser, to aid
223 braille users.
224
225 set smarthome
226 Make the Home key smarter. When Home is pressed anywhere but at the
227 very beginning of non-whitespace characters on a line, the cursor
228 will jump to that beginning (either forwards or backwards). If the
229 cursor is already at that position, it will jump to the true begin‐
230 ning of the line.
231
232 set smooth
233 Use smooth scrolling by default.
234
235 set softwrap
236 Enable soft line wrapping for easier viewing of very long lines.
237
238 set speller program
239 Use the given program to do spell checking and correcting, instead
240 of the built-in corrector that calls spell.
241
242 set statuscolor fgcolor,bgcolor
243 Specify the color combination to use for the status bar. See set
244 titlecolor for more details.
245
246 set suspend
247 Allow nano to be suspended.
248
249 set tabsize number
250 Use a tab size of number columns. The value of number must be
251 greater than 0. The default value is 8.
252
253 set tabstospaces
254 Convert typed tabs to spaces.
255
256 set tempfile
257 Save automatically on exit, don't prompt.
258
259 set titlecolor fgcolor,bgcolor
260 Specify the color combination to use for the title bar. Valid names
261 for the foreground and background colors are: white, black, blue,
262 green, red, cyan, yellow, magenta, and normal -- where normal means
263 the default foreground or background color. The name of the fore‐
264 ground color may be prefixed with bright. And either "fgcolor" or
265 ",bgcolor" may be left out.
266
267 set trimblanks
268 Remove trailing whitespace from wrapped lines when automatic hard-
269 wrapping occurs or when text is justified. (The old form of this
270 option, 'set justifytrim', is deprecated.)
271
272 set unix
273 Save a file by default in Unix format. This overrides nano's
274 default behavior of saving a file in the format that it had. (This
275 option has no effect when you also use set noconvert.)
276
277 set view
278 Disallow file modification.
279
280 set whitespace string
281 Set the two characters used to indicate the presence of tabs and
282 spaces. They must be single-column characters. The default pair
283 for a UTF-8 locale is "»⋅", and for other locales ">.".
284
285 set wordbounds
286 Detect word boundaries differently by treating punctuation charac‐
287 ters as parts of words.
288
289 set wordchars string
290 Specify which other characters (besides the normal alphanumeric
291 ones) should be considered as parts of words. This overrides the
292 option wordbounds.
293
294
296 Coloring the different syntactic elements of a file is done via regular
297 expressions (see the color command below). This is inherently imper‐
298 fect, because regular expressions are not powerful enough to fully
299 parse a file. Nevertheless, regular expressions can do a lot and are
300 easy to make, so they are a good fit for a small editor like nano.
301
302 For each kind of file a separate syntax can be defined via the follow‐
303 ing commands:
304
305 syntax name ["fileregex" ...]
306 Start the definition of a syntax with this name. All subsequent
307 color and other such commands will be added to this syntax,
308 until a new syntax command is encountered.
309
310 When nano is run, this syntax will be automatically activated if
311 the current filename matches the extended regular expression
312 fileregex. Or the syntax can be explicitly activated by using
313 the -Y or --syntax command-line option followed by the name.
314
315 The syntax default is special: it takes no fileregex, and
316 applies to files that don't match any syntax's regexes. The
317 syntax none is reserved; specifying it on the command line is
318 the same as not having a syntax at all.
319
320 header "regex" ...
321 If from all defined syntaxes no fileregex matched, then compare
322 this regex (or regexes) against the first line of the current
323 file, to determine whether this syntax should be used for it.
324
325 magic "regex" ...
326 If no fileregex matched and no header regex matched either, then
327 compare this regex (or regexes) against the result of querying
328 the magic database about the current file, to determine whether
329 this syntax should be used for it. (This functionality only
330 works when libmagic is installed on the system and will be
331 silently ignored otherwise.)
332
333 linter program [arg ...]
334 Use the given program to run a syntax check on the current buf‐
335 fer. (This overrides the speller function.)
336
337 formatter program [arg ...]
338 Use the given program to automatically reformat the text in the
339 current buffer -- useful in a programming language like Go.
340 (This overrides the speller and linter functions.)
341
342 comment "string"
343 Use the given string for commenting and uncommenting lines. If
344 the string contains a vertical bar or pipe character (|), this
345 designates bracket-style comments; for example, "/*|*/" for CSS
346 files. The characters before the pipe are prepended to the line
347 and the characters after the pipe are appended at the end of the
348 line. If no pipe character is present, the full string is
349 prepended; for example, "#" for Python files. If empty double
350 quotes are specified, the comment/uncomment function is dis‐
351 abled; for example, "" for JSON. The default value is "#".
352
353 color fgcolor,bgcolor "regex" ...
354 Display all pieces of text that match the extended regular
355 expression regex with foreground color fgcolor and background
356 color bgcolor, at least one of which must be specified. Valid
357 colors for foreground and background are: white, black, red,
358 blue, green, yellow, magenta, and cyan. You may use the prefix
359 "bright" to get a stronger color highlight for the foreground.
360 If your terminal supports transparency, not specifying a bgcolor
361 tells nano to attempt to use a transparent background.
362
363 icolor fgcolor,bgcolor "regex" ...
364 Same as above, except that the matching is case insensitive.
365
366 color fgcolor,bgcolor start="fromrx" end="torx"
367 Display all pieces of text whose start matches extended regular
368 expression fromrx and whose end matches extended regular expres‐
369 sion torx with foreground color fgcolor and background color
370 bgcolor, at least one of which must be specified. This means
371 that, after an initial instance of fromrx, all text until the
372 first instance of torx will be colored. This allows syntax
373 highlighting to span multiple lines.
374
375 icolor fgcolor,bgcolor start="fromrx" end="torx"
376 Same as above, except that the matching is case insensitive.
377
378 include "syntaxfile"
379 Read in self-contained color syntaxes from syntaxfile. Note
380 that syntaxfile may contain only the above commands, from syntax
381 to icolor.
382
383 extendsyntax name command [arg ...]
384 Extend the syntax previously defined as name with another com‐
385 mand. This allows adding a new color, icolor, header, magic,
386 comment, linter, or formatter command to an already defined syn‐
387 tax -- useful when you want to slightly improve a syntax defined
388 in one of the system-installed files (which normally are not
389 writable).
390
391
393 Key bindings can be changed via the following three commands:
394
395 bind key function menu
396 Rebinds the key key to a new function named function in the
397 context of menu menu (or in all menus where the function
398 exists by using all).
399
400 bind key "string" menu
401 Makes the given key produce the given string in the given
402 menu (or in all menus where the key exists when all is used).
403 The string can consist of text or commands or a mix of them.
404 (To enter a command into the string, precede its keystroke
405 with M-V.)
406
407
408 unbind key menu
409 Unbinds the key key from the menu named menu (or from all
410 menus where it exists by using all).
411
412
413 The format of key should be one of:
414
415 ^ followed by an alpha character or the word "Space". Example: ^C
416
417 M- followed by a printable character or the word "Space". Example:
418 M-C
419
420 F followed by a numeric value from 1 to 16. Example: F10
421
422
423 Valid function names to be bound are:
424
425 help
426 Invokes the help viewer.
427
428 cancel
429 Cancels the current command.
430
431 exit
432 Exits from the program (or from the help viewer or the file
433 browser).
434
435 writeout
436 Writes the current buffer to disk, asking for a name.
437
438 savefile
439 Writes the current file to disk without prompting.
440
441 insert
442 Inserts a file into the current buffer (at the current cursor
443 position), or into a new buffer when option multibuffer is set.
444
445 whereis
446 Starts a forward search for text in the current buffer -- or for
447 filenames matching a string in the current list in the file
448 browser.
449
450 wherewas
451 Starts a backward search for text in the current buffer.
452
453 searchagain
454 Repeats the last search command without prompting.
455
456 findprevious
457 As searchagain, but always in the backward direction.
458
459 findnext
460 As searchagain, but always in the forward direction.
461
462 replace
463 Interactively replaces text within the current buffer.
464
465 cut
466 Cuts and stores the current line (or the marked region).
467
468 copytext
469 Copies the current line (or the marked region) without deleting
470 it.
471
472 uncut
473 Copies the currently stored text into the current buffer at the
474 current cursor position.
475
476 mark
477 Sets the mark at the current position, to start selecting text.
478
479 cutwordleft
480 Cuts from the cursor position to the beginning of the preceding
481 word.
482
483 cutwordright
484 Cuts from the cursor position to the beginning of the next word.
485
486 cutrestoffile
487 Cuts all text from the cursor position till the end of the buffer.
488
489 curpos
490 Shows the current cursor position: the line, column, and character
491 positions.
492
493 wordcount
494 Counts the number of words, lines and characters in the current
495 buffer.
496
497 speller
498 Invokes a spell-checking program (or linting program, or formatter
499 program, if the active syntax defines such a thing).
500
501 linter
502 A synonym of speller (for when the speller has not been config‐
503 ured).
504
505 justify
506 Justifies the current paragraph. A paragraph is a group of con‐
507 tiguous lines that, apart from possibly the first line, all have
508 the same indentation. The beginning of a paragraph is detected by
509 either this lone line with a differing indentation or by a preced‐
510 ing blank line.
511
512 fulljustify
513 Justifies the entire current buffer.
514
515 indent
516 Indents (shifts to the right) the currently marked text.
517
518 unindent
519 Unindents (shifts to the left) the currently marked text.
520
521 comment
522 Comments or uncomments the current line or marked lines, using the
523 comment style specified in the active syntax.
524
525 complete
526 Completes the fragment before the cursor to a full word found
527 elsewhere in the current buffer.
528
529 left
530 Goes left one position (in the editor or browser).
531
532 right
533 Goes right one position (in the editor or browser).
534
535 up
536 Goes one line up (in the editor or browser).
537
538 down
539 Goes one line down (in the editor or browser).
540
541 scrollup
542 Scrolls the viewport up one row (meaning that the text slides
543 down) while keeping the cursor in the same text position, if pos‐
544 sible.
545
546 scrolldown
547 Scrolls the viewport down one row (meaning that the text slides
548 up) while keeping the cursor in the same text position, if possi‐
549 ble.
550
551 prevword
552 Moves the cursor to the beginning of the previous word.
553
554 nextword
555 Moves the cursor to the beginning of the next word.
556
557 home
558 Moves the cursor to the beginning of the current line.
559
560 end
561 Moves the cursor to the end of the current line.
562
563 beginpara
564 Moves the cursor to the beginning of the current paragraph.
565
566 endpara
567 Moves the cursor to the end of the current paragraph.
568
569 prevblock
570 Moves the cursor to the beginning of the current or preceding
571 block of text. (Blocks are separated by one or more blank lines.)
572
573 nextblock
574 Moves the cursor to the beginning of the next block of text.
575
576 pageup
577 Goes up one screenful.
578
579 pagedown
580 Goes down one screenful.
581
582 firstline
583 Goes to the first line of the file.
584
585 lastline
586 Goes to the last line of the file.
587
588 gotoline
589 Goes to a specific line (and column if specified). Negative num‐
590 bers count from the end of the file (and end of the line).
591
592 findbracket
593 Moves the cursor to the bracket (brace, parenthesis, etc.) that
594 matches (pairs) with the one under the cursor.
595
596 prevbuf
597 Switches to editing/viewing the previous buffer when multiple buf‐
598 fers are open.
599
600 nextbuf
601 Switches to editing/viewing the next buffer when multiple buffers
602 are open.
603
604 verbatim
605 Inserts the next keystroke verbatim into the file.
606
607 tab
608 Inserts a tab at the current cursor location.
609
610 enter
611 Inserts a new line below the current one.
612
613 delete
614 Deletes the character under the cursor.
615
616 backspace
617 Deletes the character before the cursor.
618
619 recordmacro
620 Starts the recording of keystrokes -- the keystrokes are stored as
621 a macro. When already recording, the recording is stopped.
622
623 runmacro
624 Replays the keystrokes of the last recorded macro.
625
626 undo
627 Undoes the last performed text action (add text, delete text,
628 etc).
629
630 redo
631 Redoes the last undone action (i.e., it undoes an undo).
632
633 refresh
634 Refreshes the screen.
635
636 suspend
637 Suspends the editor (if the suspending function is enabled, see
638 the "suspendenable" entry below).
639
640 casesens
641 Toggles case sensitivity in searching (search/replace menus only).
642
643 regexp
644 Toggles whether searching/replacing is based on literal strings or
645 regular expressions.
646
647 backwards
648 Toggles whether searching/replacing goes forward or backward.
649
650 prevhistory
651 Shows the previous history entry in the prompt menus (e.g.
652 search).
653
654 nexthistory
655 Shows the next history entry in the prompt menus (e.g. search).
656
657 flipreplace
658 Toggles between searching for something and replacing something.
659
660 flipgoto
661 Toggles between searching for text and targeting a line number.
662 (The form 'gototext' is deprecated.)
663
664 flipexecute
665 Toggles between inserting a file and executing a command.
666
667 flippipe
668 When executing a command, toggles whether the current buffer (or
669 marked region) is piped to the command.
670
671 flipnewbuffer
672 Toggles between inserting into the current buffer and into a new
673 empty buffer.
674
675 dosformat
676 When writing a file, switches to writing a DOS format (CR/LF).
677
678 macformat
679 When writing a file, switches to writing a Mac format.
680
681 append
682 When writing a file, appends to the end instead of overwriting.
683
684 prepend
685 When writing a file, 'prepends' (writes at the beginning) instead
686 of overwriting.
687
688 backup
689 When writing a file, creates a backup of the current file.
690
691 discardbuffer
692 When about to write a file, discard the current buffer without
693 saving. (This function is bound by default only when option
694 --tempfile is in effect.)
695
696 browser
697 Starts the file browser, allowing to select a file from a list.
698
699 gotodir
700 Goes to a directory to be specified, allowing to browse anywhere
701 in the filesystem.
702
703 firstfile
704 Goes to the first file when using the file browser (reading or
705 writing files).
706
707 lastfile
708 Goes to the last file when using the file browser (reading or
709 writing files).
710
711 nohelp
712 Toggles the presence of the two-line list of key bindings at the
713 bottom of the screen.
714
715 constantshow
716 Toggles the constant display of the current line, column, and
717 character positions. (The form 'constupdate' is deprecated.)
718
719 morespace
720 Toggles the presence of the blank line that 'separates' the title
721 bar from the file text.
722
723 smoothscroll
724 Toggles smooth scrolling (when moving around with the arrow keys).
725
726 softwrap
727 Toggles the displaying of overlong lines on multiple screen lines.
728
729 linenumbers
730 Toggles the display of line numbers in front of the text.
731
732 whitespacedisplay
733 Toggles the showing of whitespace.
734
735 nosyntax
736 Toggles syntax highlighting.
737
738 smarthome
739 Toggles the smartness of the Home key.
740
741 autoindent
742 Toggles whether a newly created line will contain the same amount
743 of leading whitespace as the preceding line -- or as the next line
744 if the preceding line is the beginning of a paragraph.
745
746 cutfromcursor
747 Toggles whether cutting text will cut the whole line or just from
748 the current cursor position to the end of the line. (The form
749 'cuttoend' is deprecated.)
750
751 nowrap
752 Toggles whether long lines will be hard-wrapped to the next line.
753
754 tabstospaces
755 Toggles whether typed tabs will be converted to spaces.
756
757 backupfile
758 Toggles whether a backup will be made of the file being edited.
759
760 multibuffer
761 Toggles whether a file is inserted into the current buffer or read
762 into a new buffer.
763
764 mouse
765 Toggles mouse support.
766
767 noconvert
768 Toggles automatic conversion of files from DOS/Mac format.
769
770 suspendenable
771 Toggles whether the suspend sequence (normally ^Z) will suspend
772 the editor window.
773
774
775 Valid menu sections are:
776
777 main
778 The main editor window where text is entered and edited.
779
780 search
781 The search menu (AKA whereis).
782
783 replace
784 The 'search to replace' menu.
785
786 replacewith
787 The 'replace with' menu, which comes up after 'search to replace'.
788
789 gotoline
790 The 'goto line (and column)' menu.
791
792 writeout
793 The 'write file' menu.
794
795 insert
796 The 'insert file' menu.
797
798 extcmd
799 The menu for inserting output from an external command, reached
800 from the insert menu.
801
802 help
803 The help-viewer menu.
804
805 spell
806 The interactive spell checker Yes/no menu.
807
808 linter
809 The linter menu.
810
811 browser
812 The file browser for inserting or writing a file.
813
814 whereisfile
815 The 'search for a file' menu in the file browser.
816
817 gotodir
818 The 'go to directory' menu in the file browser.
819
820 all
821 A special name that encompasses all menus. For bind it means all
822 menus where the specified function exists; for unbind it means all
823 menus where the specified key exists.
824
825
827 /etc/nanorc
828 System-wide configuration file.
829
830 ~/.nanorc or $XDG_CONFIG_HOME/nano/nanorc or ~/.config/nano/nanorc
831 Per-user configuration file.
832
833
835 nano(1)
836
837
839 Chris Allegretta and others (see the files AUTHORS and THANKS for
840 details). This manual page was originally written by Jordi Mallach for
841 the Debian system (but may be used by others).
842
843
844
845June 2018 version 2.9.8 NANORC(5)