Debian Codegraph @

upstream/opensuse-leap-16-1/man5/nanorc.5

raw
1 .\" Copyright (C) 2003-2011, 2013-2025 Free Software Foundation, Inc.
2 .\"
3 .\" This document is dual-licensed. You may distribute and/or modify it
4 .\" under the terms of either of the following licenses:
5 .\"
6 .\" * The GNU General Public License, as published by the Free Software
7 .\" Foundation, version 3 or (at your option) any later version. You
8 .\" should have received a copy of the GNU General Public License
9 .\" along with this program. If not, see
10 .\" <https://www.gnu.org/licenses/>.
11 .\"
12 .\" * The GNU Free Documentation License, as published by the Free
13 .\" Software Foundation, version 1.2 or (at your option) any later
14 .\" version, with no Invariant Sections, no Front-Cover Texts, and no
15 .\" Back-Cover Texts. You should have received a copy of the GNU Free
16 .\" Documentation License along with this program. If not, see
17 .\" <https://www.gnu.org/licenses/>.
18 .\"
19 .TH NANORC 5 "version 8.6" "August 2025"
20
21 .SH NAME
22 nanorc \- GNU nano's configuration file
23
24 .SH DESCRIPTION
25 The \fInanorc\fR files contain the default settings for \fBnano\fR,
26 a small and friendly text editor. During startup, if \fB\-\-rcfile\fR
27 is not given, \fBnano\fR reads two files: first the system-wide settings,
28 from \fI/etc/nanorc\fR (the exact path might be different on your system),
29 and then the user-specific settings, either from \fI~/.nanorc\fR or from
30 \fI$XDG_CONFIG_HOME/nano/nanorc\fR or from \fI~/.config/nano/nanorc\fR,
31 whichever is encountered first. If \fB\-\-rcfile\fR is given,
32 \fBnano\fR reads just the specified settings file.
33
34 .SH NOTICE
35 Since version 8.0, to be newcomer friendly, \fB^F\fR starts a forward search,
36 \fB^B\fR starts a backward search, \fBM\-F\fR searches the next occurrence
37 forward, and \fBM\-B\fR searches the next occurrence backward. If you want
38 those keystrokes to do what they did before version 8.0, add the following
39 lines at the end of your \fInanorc\fR file:
40 .sp
41 .RS 4
42 .B bind ^F forward main
43 .br
44 .B bind ^B back main
45 .br
46 .B bind M\-F formatter main
47 .br
48 .B bind M\-B linter main
49 .RE
50 .sp
51
52 .\" Never hyphenate these:
53 .hw ncurses terminfo
54
55 .SH OPTIONS
56 The configuration file accepts a series of \fBset\fR and \fBunset\fR
57 commands, which can be used to configure nano on startup without using
58 command-line options. Additionally, there are some commands to define
59 syntax highlighting and to rebind keys \(em see the two separate sections
60 on those. \fBnano\fR reads one command per line.
61 All commands and keywords should be written in lowercase.
62 .sp
63 Options in \fInanorc\fR files take precedence over nano's defaults, and
64 command-line options override \fInanorc\fR settings. Also, options that
65 do not take an argument are unset by default. So using the \fBunset\fR
66 command is only needed when wanting to override a setting of the system's
67 \fInanorc\fR file in your own \fInanorc\fR. Options that take an
68 argument cannot be unset.
69 .sp
70 Quotes inside the \fIcharacters\fR parameters below should not be escaped.
71 The last double quote on the line will be seen as the closing quote.
72 .sp
73 The supported commands and arguments are:
74 .TP 3
75 .B set afterends
76 Make Ctrl+Right and Ctrl+Delete stop at word ends instead of beginnings.
77 .TP
78 .B set allow_insecure_backup
79 When backing up files, allow the backup to succeed even if its permissions
80 can't be (re)set due to special OS considerations. You should
81 NOT enable this option unless you are sure you need it.
82 .TP
83 .B set atblanks
84 When soft line wrapping is enabled, make it wrap lines at blank characters
85 (tabs and spaces) instead of always at the edge of the screen.
86 .TP
87 .B set autoindent
88 Automatically indent a newly created line to the same number of tabs
89 and/or spaces as the previous line (or as the next line if the previous
90 line is the beginning of a paragraph).
91 .TP
92 .B set backup
93 When saving a file, create a backup file by adding a tilde (\fB~\fR) to
94 the file's name.
95 .TP
96 .B set backupdir \fIdirectory\fR
97 Make and keep not just one backup file, but make and keep a uniquely
98 numbered one every time a file is saved \(em when backups are enabled
99 with \fBset backup\fR or \fB\-\-backup\fR or \fB\-B\fR.
100 The uniquely numbered files are stored in the specified \fIdirectory\fR.
101 .TP
102 .B set boldtext
103 Use bold instead of reverse video for the title bar, status bar,
104 prompt bar, mini bar, key combos, line numbers, and selected text.
105 This can be overridden by setting the options \fB\%titlecolor\fR,
106 \fB\%statuscolor\fR, \fB\%promptcolor\fR, \fB\%minicolor\fR,
107 \fB\%keycolor\fR, \fB\%numbercolor\fR, and/or \fB\%selectedcolor\fR.
108 .TP
109 .B set bookstyle
110 When justifying, treat any line that starts with whitespace as the
111 beginning of a paragraph (unless auto-indenting is on).
112 .TP
113 .BI "set brackets """ characters """"
114 Set the characters treated as closing brackets when justifying
115 paragraphs. This may not include blank characters. Only closing
116 punctuation (see \fBset punct\fR), optionally followed by the specified
117 closing brackets, can end sentences. The default value is "\fB\(dq')>]}\fR".
118 .TP
119 .B set breaklonglines
120 Automatically hard-wrap the current line when it becomes overlong.
121 .TP
122 .B set casesensitive
123 Do case-sensitive searches by default.
124 .TP
125 .B set colonparsing
126 When a filename given on the command line ends in a colon plus digits
127 and this filename does not exist, then snip the colon plus digits and
128 understand the digits as a line number. If the trimmed filename does
129 not exist either, then repeat the process and understand the obtained
130 two numbers as line and column number. But if the doubly trimmed
131 filename does not exist either, then forget the trimming and accept
132 the original filename as is. To disable this colon parsing for some
133 file, use \fB+1\fR or similar before the relevant filename.
134 .TP
135 .B set constantshow
136 Constantly report the cursor position on the status bar.
137 This overrides the option \fBquickblank\fR.
138 .TP
139 .B set cutfromcursor
140 Use cut-from-cursor-to-end-of-line by default, instead of cutting the whole line.
141 .TP
142 .B set emptyline
143 Do not use the line below the title bar, leaving it entirely blank.
144 .TP
145 .B set errorcolor \fR[\fBbold,\fR][\fBitalic,\fR]\fIfgcolor\fB,\fIbgcolor\fR
146 Use this color combination for the status bar when an error message is displayed.
147 The default value is \fBbold,white,red\fR.
148 See \fBset \%titlecolor\fR for valid color names.
149 .TP
150 .B set fill \fInumber\fR
151 Set the target width for justifying and automatic hard-wrapping at this
152 \fInumber\fR of columns. If the value is 0 or less, wrapping occurs
153 at the width of the screen minus \fInumber\fR columns, allowing the wrap
154 point to vary along with the width of the screen if the screen is resized.
155 The default value is \fB\-8\fR.
156 .TP
157 .B set functioncolor \fR[\fBbold,\fR][\fBitalic,\fR]\fIfgcolor\fB,\fIbgcolor\fR
158 Use this color combination for the concise function descriptions
159 in the two help lines at the bottom of the screen.
160 See \fBset \%titlecolor\fR for more details.
161 .TP
162 .B set guidestripe \fInumber
163 Draw a vertical stripe at the given column, to help judge the width of the
164 text. (The color of the stripe can be changed with \fBset stripecolor\fR.)
165 .TP
166 .B set historylog
167 Save the last hundred search strings and replacement strings and
168 executed commands, so they can be easily reused in later sessions.
169 .TP
170 .B set indicator
171 Display a "scrollbar" on the righthand side of the edit window.
172 It shows the position of the viewport in the buffer
173 and how much of the buffer is covered by the viewport.
174 .TP
175 .B set jumpyscrolling
176 Scroll the buffer contents per half-screen instead of per line.
177 .TP
178 .B set keycolor \fR[\fBbold,\fR][\fBitalic,\fR]\fIfgcolor\fB,\fIbgcolor\fR
179 Use this color combination for the shortcut key combos
180 in the two help lines at the bottom of the screen.
181 See \fBset \%titlecolor\fR for more details.
182 .TP
183 .B set linenumbers
184 Display line numbers to the left of the text area.
185 (Any line with an anchor additionally gets a mark in the margin.)
186 .TP
187 .B set locking
188 Enable vim-style lock-files for when editing files.
189 .TP
190 .B set magic
191 When neither the file's name nor its first line give a clue,
192 try using libmagic to determine the applicable syntax.
193 (Calling libmagic can be relatively time consuming.
194 It is therefore not done by default.)
195 .TP
196 .BI "set matchbrackets """ characters """"
197 Specify the opening and closing brackets that can be found by bracket
198 searches. This may not include blank characters. The opening set must
199 come before the closing set, and the two sets must be in the same order.
200 The default value is "\fB(<[{)>]}\fR".
201 .TP
202 .B set minibar
203 Suppress the title bar and instead show information about
204 the current buffer at the bottom of the screen, in the space
205 for the status bar. In this "mini bar" the filename is shown
206 on the left, followed by an asterisk if the buffer has been modified.
207 On the right are displayed the current line and column number, the
208 code of the character under the cursor (in Unicode format: U+xxxx),
209 the same flags as are shown by \fBset stateflags\fR, and a percentage
210 that expresses how far the cursor is into the file (linewise).
211 When a file is loaded or saved, and also when switching between buffers,
212 the number of lines in the buffer is displayed after the filename.
213 This number is cleared upon the next keystroke, or replaced with an
214 [i/n] counter when multiple buffers are open.
215 The line plus column numbers and the character code are displayed only when
216 \fBset constantshow\fR is used, and can be toggled on and off with \fBM\-C\fR.
217 The state flags are displayed only when \fBset stateflags\fR is used.
218 .TP
219 .B set minicolor \fR[\fBbold,\fR][\fBitalic,\fR]\fIfgcolor\fB,\fIbgcolor\fR
220 Use this color combination for the mini bar.
221 (When this option is not specified, the colors of the title bar are used.)
222 See \fBset \%titlecolor\fR for more details.
223 .TP
224 .B set mouse
225 Enable mouse support, if available for your system. When enabled,
226 mouse clicks can be used to place the cursor, set the mark (with two
227 clicks), and execute shortcuts. The mouse works in the X Window
228 System, and on the console when gpm is running. Text can still be
229 selected through dragging by holding down the Shift key.
230 .TP
231 .B set multibuffer
232 When reading in a file with \fB^R\fR, insert it into a new buffer by default.
233 .TP
234 .B set noconvert
235 Don't convert files from DOS/Mac format.
236 .TP
237 .B set nohelp
238 Don't display the two help lines at the bottom of the screen.
239 .TP
240 .B set nonewlines
241 Don't automatically add a newline when a text does not end with one.
242 (This can cause you to save non-POSIX text files.)
243 .TP
244 .B set nowrap
245 Deprecated option since it has become the default setting.
246 When needed, use \fBunset breaklonglines\fR instead.
247 .TP
248 .B set numbercolor \fR[\fBbold,\fR][\fBitalic,\fR]\fIfgcolor\fB,\fIbgcolor\fR
249 Use this color combination for line numbers.
250 See \fBset \%titlecolor\fR for more details.
251 .TP
252 .B set operatingdir \fIdirectory\fR
253 At startup, make \fBnano\fR change to the given \fIdirectory\fR, and allow
254 reading and writing files only in this directory and its subdirectories.
255 .TP
256 .B set positionlog
257 Save the positions of cursor and anchors between editing sessions.
258 These positions are remembered for the 200 most-recently edited files.
259 .TP
260 .B set preserve
261 Preserve the XOFF and XON sequences (\fB^S\fR and \fB^Q\fR) so that
262 they are caught by the terminal (stopping and resuming the output).
263 .TP
264 .B set promptcolor \fR[\fBbold,\fR][\fBitalic,\fR]\fIfgcolor\fB,\fIbgcolor\fR
265 Use this color combination for the prompt bar.
266 (When this option is not specified, the colors of the title bar are used.)
267 See \fBset \%titlecolor\fR for more details.
268 .TP
269 .BI "set punct """ characters """"
270 Set the characters treated as closing punctuation when justifying
271 paragraphs. This may not include blank characters. Only the
272 specified closing punctuation, optionally followed by closing brackets
273 (see \fBset brackets\fR), can end sentences. The default value is "\fB!.?\fR".
274 .TP
275 .B set quickblank
276 Make status-bar messages disappear after 1 keystroke instead of after 20.
277 Note that option \fBconstantshow\fR overrides this.
278 When option \fBminibar\fR or \fBzero\fR is in effect,
279 \fBquickblank\fR makes a message disappear after
280 0.8 seconds instead of after the default 1.5 seconds.
281 .TP
282 .BI "set quotestr """ regex """"
283 Set the regular expression for matching the quoting part of a line.
284 The default value is "\fB^([\ \et]*([!#%:;>|}]|//))+\fR".
285 (Note that \fB\et\fR stands for an actual Tab character.)
286 This makes it possible to rejustify blocks of quoted text when composing
287 email, and to rewrap blocks of line comments when writing source code.
288 .TP
289 .B set rawsequences
290 Interpret escape sequences directly, instead of asking \fBncurses\fR
291 to translate them. (If you need this option to get some keys to work
292 properly, it means that the \fBterminfo\fR terminal description that is used
293 does not fully match the actual behavior of your terminal. This can
294 happen when you ssh into a BSD machine, for example.)
295 Using this option disables \fBnano\fR's mouse support.
296 .TP
297 .B set rebinddelete
298 Interpret the Delete and Backspace keys differently so that both Backspace
299 and Delete work properly. You should only use this option when on your
300 system either Backspace acts like Delete or Delete acts like Backspace.
301 .TP
302 .B set regexp
303 Do regular-expression searches by default.
304 Regular expressions in \fBnano\fR are of the extended type (ERE).
305 .TP
306 .B set saveonexit
307 Save a changed buffer automatically on exit (\fB^X\fR); don't prompt.
308 .TP
309 .B set scrollercolor \fIfgcolor\fB,\fIbgcolor\fR
310 Use this color combination for the indicator alias "scrollbar".
311 See \fBset \%titlecolor\fR for more details.
312 .TP
313 .B set selectedcolor \fR[\fBbold,\fR][\fBitalic,\fR]\fIfgcolor\fB,\fIbgcolor\fR
314 Use this color combination for selected text.
315 See \fBset \%titlecolor\fR for more details.
316 .TP
317 .B set showcursor
318 Put the cursor on the highlighted item in the file browser, and show
319 the cursor in the help viewer, to aid braille users and people with
320 poor vision.
321 .TP
322 .B set smarthome
323 Make the Home key smarter. When Home is pressed anywhere but at the
324 very beginning of non-whitespace characters on a line, the cursor jumps
325 to that beginning (either forwards or backwards). If the cursor is
326 already at that position, it jumps to the true beginning of the line.
327 .TP
328 .B set softwrap
329 Display lines that exceed the screen's width over multiple screen lines.
330 (You can make this soft-wrapping occur at whitespace instead of rudely at
331 the screen's edge, by using also \fBset atblanks\fR.)
332 .TP
333 .B set speller """\fIprogram\fR [\fIargument \fR...]\fB"""
334 Use the given \fIprogram\fR to do spell checking and correcting, instead of
335 using the built-in corrector that calls \fBhunspell\fR(1) or \fBspell\fR(1).
336 .TP
337 .B set spotlightcolor \fR[\fBbold,\fR][\fBitalic,\fR]\fIfgcolor\fB,\fIbgcolor\fR
338 Use this color combination for highlighting a search match.
339 The default value is \fBblack,\%lightyellow\fR.
340 See \fBset \%titlecolor\fR for valid color names.
341 .TP
342 .B set stateflags
343 Use the top-right corner of the screen for showing some state flags:
344 \fBI\fR when auto-indenting, \fBM\fR when the mark is on, \fBL\fR when
345 hard-wrapping (breaking long lines), \fBR\fR when recording a macro,
346 and \fBS\fR when soft-wrapping.
347 When the buffer is modified, a star (\fB*\fR) is shown after the
348 filename in the center of the title bar.
349 .TP
350 .B set statuscolor \fR[\fBbold,\fR][\fBitalic,\fR]\fIfgcolor\fB,\fIbgcolor\fR
351 Use this color combination for the status bar.
352 See \fBset \%titlecolor\fR for more details.
353 .TP
354 .B set stripecolor \fR[\fBbold,\fR][\fBitalic,\fR]\fIfgcolor\fB,\fIbgcolor\fR
355 Use this color combination for the vertical guiding stripe.
356 See \fBset \%titlecolor\fR for more details.
357 .TP
358 .B set tabsize \fInumber\fR
359 Use a tab size of \fInumber\fR columns. The value of \fInumber\fR must be
360 greater than 0. The default value is \fB8\fR.
361 .TP
362 .B set tabstospaces
363 Convert each typed tab to spaces \(em to the number of spaces
364 that a tab at that position would take up.
365 (Note: pasted tabs are not converted.)
366 .TP
367 .B set titlecolor \fR[\fBbold,\fR][\fBitalic,\fR]\fIfgcolor\fB,\fIbgcolor\fR
368 Use this color combination for the title bar.
369 Valid names for the foreground and background colors are:
370 .BR red ", " green ", " blue ", " \%magenta ", " \%yellow ", " \%cyan ,
371 .BR white ", and " black .
372 Each of these eight names may be prefixed with the word \fBlight\fR
373 to get a brighter version of that color.
374 The word \fBgrey\fR or \fBgray\fR may be used
375 as a synonym for \fB\%lightblack\fR.
376 On a Linux console, \fBlight\fR does not have
377 any effect for a background color.
378 On terminal emulators that can do at least 256 colors,
379 other valid (but unprefixable) color names are:
380 .BR pink ", " \%purple ", " mauve ", " \%lagoon ", " mint ", " lime ", " peach ,
381 .BR \%orange ", " \%latte ", " \%rosy ", " beet ", " plum ", " sea ", " sky ,
382 .BR slate ", " teal ", " sage ", " brown ", " \%ocher ", " sand ", " \%tawny ,
383 .BR brick ", " \%crimson ", and " \%normal
384 \(em where \fB\%normal\fR means the default foreground or background color.
385 On such emulators, the color may also be specified as a three-digit hexadecimal
386 number prefixed with \fB#\fR, with the digits representing the amounts of red,
387 green, and blue, respectively. This tells \fBnano\fR to select from the
388 available palette the color that approximates the given values.
389
390 Either "\fIfgcolor\fR" or "\fB,\fIbgcolor\fR" may be left out,
391 and the pair may be preceded by \fBbold\fR and/or \fB\%italic\fR
392 (separated by commas) to get a bold and/or slanting typeface,
393 if your terminal can do those.
394 .TP
395 .B set trimblanks
396 Remove trailing whitespace from wrapped lines when automatic
397 hard-wrapping occurs or when text is justified.
398 .TP
399 .B set unix
400 Save a file by default in Unix format. This overrides nano's
401 default behavior of saving a file in the format that it had.
402 (This option has no effect when you also use \fBset noconvert\fR.)
403 .TP
404 .BI "set whitespace """ characters """"
405 Set the two characters used to indicate the presence of tabs and
406 spaces. They must be single-column characters. The default pair
407 for a UTF-8 locale is "\fB\[Fc]\[md]\fR", and for other locales "\fB>.\fR".
408 .TP
409 .B set wordbounds
410 Detect word boundaries differently by treating punctuation
411 characters as parts of words.
412 .TP
413 .BI "set wordchars """ characters """"
414 Specify which other characters (besides the normal alphanumeric ones)
415 should be considered as parts of words. When using this option, you
416 probably want to unset \fBwordbounds\fR.
417 .TP
418 .B set zap
419 Let an unmodified Backspace or Delete erase the marked region
420 (instead of a single character, and without affecting the cutbuffer).
421 .TP
422 .B set zero
423 Hide all elements of the interface (title bar, status bar, and help lines)
424 and use all rows of the terminal for showing the contents of the buffer.
425 The status bar appears only when there is a significant message,
426 and disappears after 1.5 seconds or upon the next keystroke.
427 With \fBM\-Z\fR the title bar plus status bar can be toggled.
428 With \fBM\-X\fR the help lines.
429
430 .SH SYNTAX HIGHLIGHTING
431 Coloring the different syntactic elements of a file
432 is done via regular expressions (see the \fBcolor\fR command below).
433 This is inherently imperfect, because regular expressions are not
434 powerful enough to fully parse a file. Nevertheless, regular
435 expressions can do a lot and are easy to make, so they are a
436 good fit for a small editor like \fBnano\fR.
437 .sp
438 All regular expressions in \fBnano\fR are POSIX extended regular expressions.
439 This means that \fB.\fR, \fB?\fR, \fB*\fR, \fB+\fR, \fB^\fR, \fB$\fR, and
440 several other characters are special.
441 The period \fB.\fR matches any single character,
442 \fB?\fR means the preceding item is optional,
443 \fB*\fR means the preceding item may be matched zero or more times,
444 \fB+\fR means the preceding item must be matched one or more times,
445 \fB^\fR matches the beginning of a line, and \fB$\fR the end,
446 \fB\e<\fR matches the start of a word, and \fB\e>\fR the end,
447 and \fB\es\fR matches a blank.
448 It also means that lookahead and lookbehind are not possible.
449 A complete explanation can be found in the manual page of GNU grep:
450 \fBman grep\fR.
451 .sp
452 Each regular expression in a \fBnanorc\fR file should be wrapped in
453 double quotes (\fB""\fR). Multiple regular expressions can follow
454 each other on a line by separating them with blanks. This means that
455 a regular expression cannot contain a double quote followed by a blank.
456 When you need this combination inside a regular expression,
457 then either the double quote or the blank should be put
458 between square brackets (\fB[]\fR).
459 .sp
460 For each kind of file a separate syntax can be defined
461 via the following commands:
462 .TP
463 .BI syntax " name \fR[" """" fileregex """ " \fR...]
464 Start the definition of a syntax with this \fIname\fR.
465 All subsequent \fBcolor\fR and other such commands
466 are added to this syntax, until a new \fBsyntax\fR
467 command is encountered.
468 .sp
469 When \fBnano\fR is run, this syntax is automatically
470 activated (for the relevant buffer) if the absolute filename
471 matches the extended regular expression \fIfileregex\fR.
472 Or the syntax can be explicitly activated (for all buffers)
473 by using the \fB\-Y\fR or \fB\-\-syntax\fR
474 command-line option followed by the \fIname\fR.
475 .sp
476 The syntax \fBdefault\fR is special: it takes no \fIfileregex\fR,
477 and applies to files that don't match any syntax's regexes.
478 The syntax \fBnone\fR is reserved; specifying it on the command line
479 is the same as not having a syntax at all.
480 .TP
481 .BI "header """ regex """ " \fR...
482 If from all defined syntaxes no \fIfileregex\fR matched, then compare
483 this \fIregex\fR (or regexes) against the first line of the current file,
484 to determine whether this syntax should be used for it.
485 .TP
486 .BI "magic """ regex """ " \fR...
487 If no \fIfileregex\fR matched and no \fBheader\fR regex matched
488 either, then compare this \fIregex\fR (or regexes) against the
489 result of querying the \fBmagic\fR database about the current
490 file, to determine whether this syntax should be used for it.
491 (This querying is done only when \fBlibmagic\fR is actually installed
492 on the system and \fB\-\-magic\fR or \fBset magic\fR was given.)
493 .TP
494 .BI formatter " program " \fR[ "argument " \fR...]
495 Run the given \fIprogram\fR on the full contents of the current buffer.
496 .TP
497 .BI linter " program " \fR[ "argument " \fR...]
498 Use the given \fIprogram\fR to run a syntax check on the current buffer.
499 .TP
500 .BI "comment """ string """"
501 Use the given \fIstring\fR for commenting and uncommenting lines.
502 If the string contains a vertical bar or pipe character (\fB|\fR),
503 this designates bracket-style comments; for example, "\fB/*|*/\fR" for
504 CSS files. The characters before the pipe are prepended to the line and the
505 characters after the pipe are appended at the end of the line. If no pipe
506 character is present, the full string is prepended; for example, "\fB#\fR"
507 for Python files. If empty double quotes are specified, the comment/uncomment
508 function is disabled; for example, "" for JSON.
509 The default value is "\fB#\fR".
510 .TP
511 .BI "tabgives """ string """"
512 Make the <Tab> key produce the given \fIstring\fR. Useful for languages like
513 Python that want to see only spaces for indentation.
514 This overrides the setting of the \fBtabstospaces\fR option.
515 .TP
516 .BI "color \fR[\fBbold,\fR][\fBitalic,\fR]" fgcolor , bgcolor " """ regex """ " \fR...
517 Paint all pieces of text that match the extended regular expression
518 \fIregex\fR with the given foreground and background colors, at least
519 one of which must be specified. Valid color names are:
520 .BR red ", " green ", " blue ", " \%magenta ", " \%yellow ", " \%cyan ,
521 .BR white ", and " black .
522 Each of these eight names may be prefixed with the word \fBlight\fR
523 to get a brighter version of that color.
524 The word \fBgrey\fR or \fBgray\fR may be used
525 as a synonym for \fB\%lightblack\fR.
526 On a Linux console, \fBlight\fR does not have
527 any effect for a background color.
528 On terminal emulators that can do at least 256 colors,
529 other valid (but unprefixable) color names are:
530 .BR pink ", " \%purple ", " mauve ", " \%lagoon ", " mint ", " lime ", " peach ,
531 .BR \%orange ", " \%latte ", " \%rosy ", " beet ", " plum ", " sea ", " sky ,
532 .BR slate ", " teal ", " sage ", " brown ", " \%ocher ", " sand ", " \%tawny ,
533 .BR brick ", " \%crimson ", and " \%normal
534 \(em where \fB\%normal\fR means the default foreground or background color.
535 On such emulators, the color may also be specified as a three-digit hexadecimal
536 number prefixed with \fB#\fR, with the digits representing the amounts of red,
537 green, and blue, respectively. This tells \fBnano\fR to select from the
538 available palette the color that approximates the given values.
539
540 The color pair may be preceded by \fBbold\fR and/or \fB\%italic\fR
541 (separated by commas) to get a bold and/or slanting typeface,
542 if your terminal can do those.
543 .sp
544 All coloring commands are applied in the order in which they are specified,
545 which means that later commands can recolor stuff that was colored earlier.
546 .TP
547 .BI "icolor \fR[\fBbold,\fR][\fBitalic,\fR]" fgcolor , bgcolor " """ regex """ " \fR...
548 Same as above, except that the matching is case insensitive.
549 .TP
550 .BI "color \fR[\fBbold,\fR][\fBitalic,\fR]" fgcolor , bgcolor " start=""" fromrx """ end=""" torx """"
551 Paint all pieces of text whose start matches extended regular expression
552 \fIfromrx\fR and whose end matches extended regular expression \fItorx\fR
553 with the given foreground and background colors,
554 at least one of which must be specified. This means that, after an
555 initial instance of \fIfromrx\fR, all text until the first instance of
556 \fItorx\fR is colored. This allows syntax highlighting to span
557 multiple lines.
558 .TP
559 .BI "icolor \fR[\fBbold,\fR][\fBitalic,\fR]" fgcolor , bgcolor " start=""" fromrx """ end=""" torx """"
560 Same as above, except that the matching is case insensitive.
561 .TP
562 .BI "include """ syntaxfile """"
563 Read in self-contained color syntaxes from \fIsyntaxfile\fR. Note that
564 \fIsyntaxfile\fR may contain only the above commands, from \fBsyntax\fR
565 to \fBicolor\fR.
566 .TP
567 .BI extendsyntax " name command argument " \fR...
568 Extend the syntax previously defined as \fIname\fR with another
569 \fI\%command\fR. This allows adding a new \fB\%color\fR, \fB\%icolor\fR,
570 \fB\%header\fR, \fB\%magic\fR, \fB\%formatter\fR, \fB\%linter\fR,
571 \fB\%comment\fR, or \fB\%tabgives\fR
572 command to an already defined syntax \(em useful when you want to
573 slightly improve a syntax defined in one of the system-installed
574 files (which normally are not writable).
575
576 .SH REBINDING KEYS
577 Key bindings can be changed via the following three commands:
578 .RS 3
579 .TP
580 .BI bind " key function menu"
581 Rebinds the given \fIkey\fR to the given \fIfunction\fR in the given \fImenu\fR
582 (or in all menus where the function exists when \fBall\fR is used).
583 .TP
584 .BI bind " key " """" string """" " menu"
585 Makes the given \fIkey\fR produce the given \fIstring\fR in the given
586 \fImenu\fR (or in all menus where the key exists when \fBall\fR is used).
587 Besides literal text and/or control codes, the \fIstring\fR may contain
588 function names between braces. These functions are invoked when
589 the key is typed. To include a literal opening brace, use \fB{{}\fR.
590 .TP
591 .BI unbind " key menu"
592 Unbinds the given \fIkey\fR from the given \fImenu\fR (or from all
593 menus where the key exists when \fBall\fR is used).
594 .RE
595 .sp
596 Note that \fBbind \fIkey\fR \fB"{\fIfunction\fB}"\fR \fImenu\fR is equivalent
597 to \fBbind \fIkey\fR \fIfunction\fR \fImenu\fR, except that for the latter form
598 \fBnano\fR checks the availability of the \fIfunction\fR in the given \fImenu\fR
599 at startup time (and reports an error if it does not exist there), whereas for the
600 first form \fBnano\fR checks at execution time that the \fIfunction\fR exists
601 but not whether it makes any sense in the current menu. The user has to take care
602 that a function name between braces (or any sequence of them) is appropriate.
603 Strange behavior or even a crash can result when the braced name is unfitting.
604
605 .TP
606 The format of \fIkey\fR should be one of:
607 .RS 3
608 .TP 7
609 .BI ^ X
610 where \fIX\fR is a Latin letter, or one of several ASCII characters
611 (@, ], \e, ^, _), or the word "Space".
612 Example: ^C.
613 .TP
614 .BI M\- X
615 where \fIX\fR is any ASCII character except [, or the word "Space".
616 Example: M\-8.
617 .TP
618 .BI Sh\-M\- X
619 where \fIX\fR is a Latin letter.
620 Example: Sh\-M\-U.
621 By default, each Meta+letter keystroke does the same as the corresponding
622 Shift+Meta+letter. But when any Shift+Meta bind is made, that will
623 no longer be the case, for all letters.
624 .TP
625 .BI F N
626 where \fIN\fR is a numeric value from 1 to 24.
627 Example: F10.
628 (Often, \fBF13\fR to \fBF24\fR can be typed as \fBF1\fR to \fBF12\fR with Shift.)
629 .TP
630 .BR Ins " or " Del .
631 .RE
632 .sp
633 Rebinding \fB^M\fR (Enter) or \fB^I\fR (Tab) is probably not a good idea.
634 Rebinding \fB^[\fR (Esc) is not possible, because its keycode
635 is the starter byte of Meta keystrokes and escape sequences.
636 Rebinding any of the dedicated cursor-moving keys (the arrows,
637 Home, End, PageUp and PageDown) is not possible.
638 On some terminals it's not possible to rebind \fB^H\fR (unless \fB\-\-raw\fR
639 is used) because its keycode is identical to that of the Backspace key.
640
641 .TP
642 Valid \fIfunction\fR names to be bound are:
643 .RS 3
644 .TP 2
645 .B help
646 Invokes the help viewer.
647 .TP
648 .B cancel
649 Cancels the current command.
650 .TP
651 .B exit
652 Exits from the program (or from the help viewer or file browser).
653 .TP
654 .B writeout
655 Writes the current buffer to disk, asking for a name.
656 .TP
657 .B savefile
658 Writes the current file to disk without prompting.
659 .TP
660 .B insert
661 Inserts a file into the current buffer (at the current cursor position),
662 or into a new buffer when option \fBmultibuffer\fR is set.
663 .TP
664 .B whereis
665 Starts a forward search for text in the current buffer \(em or for filenames
666 matching a string in the current list in the file browser.
667 .TP
668 .B wherewas
669 Starts a backward search for text in the current buffer \(em or for filenames
670 matching a string in the current list in the file browser.
671 .TP
672 .B findprevious
673 Searches the next occurrence in the backward direction.
674 .TP
675 .B findnext
676 Searches the next occurrence in the forward direction.
677 .TP
678 .B replace
679 Interactively replaces text within the current buffer.
680 .TP
681 .B cut
682 Cuts and stores the current line (or the marked region).
683 .TP
684 .B copy
685 Copies the current line (or the marked region) without deleting it.
686 .TP
687 .B paste
688 Pastes the currently stored text into the current buffer at the
689 current cursor position.
690 .TP
691 .B zap
692 Throws away the current line (or the marked region).
693 (This function is bound by default to <Meta+Delete>.)
694 .TP
695 .B chopwordleft
696 Deletes from the cursor position to the beginning of the preceding word.
697 (This function is bound by default to <Shift+Ctrl+Delete>. If your terminal
698 produces \fB^H\fR for <Ctrl+Backspace>, you can make <Ctrl+Backspace> delete
699 the word to the left of the cursor by rebinding \fB^H\fR to this function.)
700 .TP
701 .B chopwordright
702 Deletes from the cursor position to the beginning of the next word.
703 (This function is bound by default to <Ctrl+Delete>.)
704 .TP
705 .B cutrestoffile
706 Cuts all text from the cursor position till the end of the buffer.
707 .TP
708 .B mark
709 Sets the mark at the current position, to start selecting text.
710 Or, when it is set, unsets the mark.
711 .TP
712 .B location
713 Reports the current position of the cursor in the buffer:
714 the line, column, and character positions.
715 .TP
716 .B wordcount
717 Counts and reports on the status bar the number of lines, words,
718 and characters in the current buffer (or in the marked region).
719 .TP
720 .B execute
721 Prompts for a program to execute. The program's output is inserted
722 into the current buffer (or into a new buffer when \fBM\-F\fR is toggled).
723 .TP
724 .B speller
725 Invokes a spell-checking program, either the default \fBhunspell\fR(1) or GNU
726 \fBspell\fR(1), or the one defined by \fB\-\-speller\fR or \fBset speller\fR.
727 .TP
728 .B formatter
729 Invokes a full-buffer-processing program (if the active syntax defines one).
730 (The current buffer is written out to a temporary file, the program
731 is run on it, and then the temporary file is read back in, replacing
732 the contents of the buffer.)
733 .TP
734 .B linter
735 Invokes a syntax-checking program (if the active syntax defines one).
736 If this program produces lines of the form "filename:linenum:charnum:
737 some message", then the cursor is put at the indicated position
738 in the mentioned file while showing "some message" on the status bar.
739 You can move from message to message with <PgUp> and <PgDn>,
740 and leave linting mode with \fB^C\fR or <Enter>.
741 .TP
742 .B justify
743 Justifies the current paragraph (or the marked region).
744 A paragraph is a group of contiguous lines that, apart from possibly
745 the first line, all have the same indentation. The beginning of a
746 paragraph is detected by either this lone line with a differing
747 indentation or by a preceding blank line.
748 .TP
749 .B fulljustify
750 Justifies the entire current buffer (or the marked region).
751 .TP
752 .B indent
753 Indents (shifts to the right) the current line or the marked lines.
754 .TP
755 .B unindent
756 Unindents (shifts to the left) the current line or the marked lines.
757 .TP
758 .B comment
759 Comments or uncomments the current line or the marked lines,
760 using the comment style specified in the active syntax.
761 .TP
762 .B complete
763 Completes (when possible) the fragment before the cursor
764 to a full word found elsewhere in the current buffer.
765 .TP
766 .B left
767 Goes left one position (in the editor or browser).
768 .TP
769 .B right
770 Goes right one position (in the editor or browser).
771 .TP
772 .B up
773 Goes one line up (in the editor or browser).
774 .TP
775 .B down
776 Goes one line down (in the editor or browser).
777 .TP
778 .B scrollup
779 Scrolls the viewport up one row (meaning that the text slides down)
780 while keeping the cursor in the same text position, if possible.
781 (This function is bound by default to <Alt+Up>.
782 If <Alt+Up> does nothing on your Linux console, see the FAQ:
783 .UR https://nano\-editor.org/dist/latest/faq.html#4.1
784 .UE .)
785 .TP
786 .B scrolldown
787 Scrolls the viewport down one row (meaning that the text slides up)
788 while keeping the cursor in the same text position, if possible.
789 (This function is bound by default to <Alt+Down>.)
790 .TP
791 .B center
792 Scrolls the line with the cursor to the middle of the viewport.
793 .TP
794 .B cycle
795 Scrolls the line with the cursor first to the middle of the viewport,
796 then to the top, then to the bottom.
797 .TP
798 .B prevword
799 Moves the cursor to the beginning of the previous word.
800 .TP
801 .B nextword
802 Moves the cursor to the beginning of the next word.
803 .TP
804 .B home
805 Moves the cursor to the beginning of the current line.
806 .TP
807 .B end
808 Moves the cursor to the end of the current line.
809 .TP
810 .B beginpara
811 Moves the cursor to the beginning of the current paragraph.
812 .TP
813 .B endpara
814 Moves the cursor to the end of the current paragraph.
815 .TP
816 .B prevblock
817 Moves the cursor to the beginning of the current or preceding block of text.
818 (Blocks are separated by one or more blank lines.)
819 .TP
820 .B nextblock
821 Moves the cursor to the beginning of the next block of text.
822 .TP
823 .B toprow
824 Moves the cursor to the first row in the viewport.
825 .TP
826 .B bottomrow
827 Moves the cursor to the last row in the viewport.
828 .TP
829 .B pageup
830 Goes up one screenful.
831 .TP
832 .B pagedown
833 Goes down one screenful.
834 .TP
835 .B firstline
836 Goes to the first line of the file.
837 .TP
838 .B lastline
839 Goes to the last line of the file.
840 .TP
841 .B gotoline
842 Goes to a specific line (and column if given).
843 A negative number counts from the end of the buffer (and end of the line).
844 Putting \fB++\fR or \fB\-\-\fR before the first number will jump the given
845 number of lines forward or backward.
846 .TP
847 .B findbracket
848 Moves the cursor to the bracket (or brace or parenthesis, etc.\&) that matches
849 (pairs) with the one under the cursor. See \fBset matchbrackets\fR.
850 .TP
851 .B anchor
852 Places an anchor at the current line, or removes it when already present.
853 (An anchor is visible when line numbers are activated.)
854 .TP
855 .B prevanchor
856 Goes to the first anchor before the current line.
857 .TP
858 .B nextanchor
859 Goes to the first anchor after the current line.
860 .TP
861 .B prevbuf
862 Switches to editing/viewing the previous buffer when multiple buffers are open.
863 .TP
864 .B nextbuf
865 Switches to editing/viewing the next buffer when multiple buffers are open.
866 .TP
867 .B verbatim
868 Inserts the next keystroke verbatim into the file, or begins Unicode input
869 when a hexadecimal digit is typed.
870 .TP
871 .B tab
872 Inserts a tab at the current cursor location.
873 .TP
874 .B enter
875 Inserts a new line below the current one.
876 .TP
877 .B delete
878 Deletes the character under the cursor.
879 .TP
880 .B backspace
881 Deletes the character before the cursor.
882 .TP
883 .B recordmacro
884 Starts the recording of keystrokes \(em the keystrokes are stored
885 as a macro. When already recording, the recording is stopped.
886 .TP
887 .B runmacro
888 Replays the keystrokes of the last recorded macro.
889 .TP
890 .B undo
891 Undoes the last performed text action (add text, delete text, etc).
892 .TP
893 .B redo
894 Redoes the last undone action (i.e., it undoes an undo).
895 .TP
896 .B refresh
897 Refreshes the screen.
898 .TP
899 .B suspend
900 Suspends the editor and returns control to the shell
901 (until you tell the process to resume execution with \fBfg\fR).
902 .TP
903 .B casesens
904 Toggles whether searching/replacing ignores or respects the case of
905 the given characters.
906 .TP
907 .B regexp
908 Toggles whether searching/replacing uses literal strings or regular expressions.
909 .TP
910 .B backwards
911 Toggles whether searching/replacing goes forward or backward.
912 .TP
913 .B older
914 Retrieves the previous (earlier) entry at a prompt.
915 .TP
916 .B newer
917 Retrieves the next (later) entry at a prompt.
918 .TP
919 .B flipreplace
920 Toggles between searching for something and replacing something.
921 .TP
922 .B flipgoto
923 Toggles between searching for text and targeting a line number.
924 .TP
925 .B flipexecute
926 Switches from inserting a file to executing a command.
927 .TP
928 .B flippipe
929 When executing a command, toggles whether the current buffer (or marked
930 region) is piped to the command.
931 .TP
932 .B flipnewbuffer
933 Toggles between inserting into the current buffer and into a new
934 empty buffer.
935 .TP
936 .B flipconvert
937 When reading in a file, toggles between converting and not converting
938 it from DOS/Mac format. Converting is the default.
939 .TP
940 .B dosformat
941 When writing a file, switches to writing a DOS format (CR/LF).
942 .TP
943 .B macformat
944 When writing a file, switches to writing a Mac format.
945 .TP
946 .B append
947 When writing a file, appends to the end instead of overwriting.
948 .TP
949 .B prepend
950 When writing a file, "prepends" (writes at the beginning) instead of overwriting.
951 .TP
952 .B backup
953 When writing a file, creates a backup of the current file.
954 .TP
955 .B discardbuffer
956 When about to write a file, discard the current buffer without saving.
957 (This function is bound by default only when option \fB\-\-saveonexit\fR
958 is in effect.)
959 .TP
960 .B browser
961 Starts the file browser (in the Read File and Write Out menus),
962 allowing to select a file from a list.
963 .TP
964 .B gotodir
965 Goes to a directory to be specified, allowing to browse anywhere
966 in the filesystem.
967 .TP
968 .B firstfile
969 Goes to the first file in the list when using the file browser.
970 .TP
971 .B lastfile
972 Goes to the last file in the list when using the file browser.
973 .TP
974 .B nohelp
975 Toggles the presence of the two-line list of key bindings at the bottom of the screen.
976 (This toggle is special: it is available in all menus except the help viewer
977 and the linter. All further toggles are available in the main menu only.)
978 .TP
979 .B zero
980 Toggles the presence of title bar and status bar.
981 .TP
982 .B constantshow
983 Toggles the constant reporting (on the status bar)
984 of the current line, column, and character positions.
985 .TP
986 .B softwrap
987 Toggles the displaying of overlong lines on multiple screen lines.
988 .TP
989 .B linenumbers
990 Toggles the display of line numbers in front of the text.
991 .TP
992 .B whitespacedisplay
993 Toggles the showing of whitespace.
994 .TP
995 .B nosyntax
996 Toggles syntax highlighting.
997 .TP
998 .B smarthome
999 Toggles the smartness of the Home key.
1000 .TP
1001 .B autoindent
1002 Toggles whether a newly created line will contain the same amount of leading
1003 whitespace as the preceding line \(em or as the next line if the preceding line
1004 is the beginning of a paragraph.
1005 .TP
1006 .B cutfromcursor
1007 Toggles whether cutting text cuts the whole line or just from the current cursor
1008 position to the end of the line.
1009 .TP
1010 .B breaklonglines
1011 Toggles whether the overlong part of a line is hard-wrapped to the next line.
1012 .TP
1013 .B tabstospaces
1014 Toggles whether typed tabs are converted to spaces.
1015 .TP
1016 .B mouse
1017 Toggles mouse support.
1018 .RE
1019
1020 .TP
1021 Valid \fImenu\fR sections are:
1022 .RS 3
1023 .TP 2
1024 .B main
1025 The main editor window where text is entered and edited.
1026 .TP
1027 .B help
1028 The help-viewer menu.
1029 .TP
1030 .B search
1031 The search menu (AKA whereis).
1032 .TP
1033 .B replace
1034 The \&'search to replace' menu.
1035 .TP
1036 .B replacewith
1037 The \&'replace with' menu, which comes up after \&'search to replace'.
1038 .TP
1039 .B yesno
1040 The \&'yesno' menu, where the Yes/No/All/Cancel question is asked.
1041 .TP
1042 .B gotoline
1043 The \&'goto line (and column)' menu.
1044 .TP
1045 .B writeout
1046 The \&'write file' menu.
1047 .TP
1048 .B insert
1049 The \&'insert file' menu.
1050 .TP
1051 .B browser
1052 The \&'file browser' menu, for selecting a file to be opened or
1053 inserted or written to.
1054 .TP
1055 .B whereisfile
1056 The \&'search for a file' menu in the file browser.
1057 .TP
1058 .B gotodir
1059 The \&'go to directory' menu in the file browser.
1060 .TP
1061 .B execute
1062 The menu for inserting the output from an external command,
1063 or for filtering the buffer (or the marked region) through
1064 an external command, or for executing one of several tools.
1065 .TP
1066 .B spell
1067 The menu of the integrated spell checker where the user can edit a misspelled word.
1068 .TP
1069 .B linter
1070 The linter menu, which allows jumping through the linting messages.
1071 .TP
1072 .B all
1073 A special name that encompasses all menus.
1074 For \fBbind\fR it means all menus where the specified \fIfunction\fR exists;
1075 for \fBunbind\fR it means all menus where the specified \fIkey\fR exists.
1076 .RE
1077
1078 .SH EXAMPLES
1079 To make \fBCtrl+Z\fR suspend nano:
1080 .sp
1081 .RS
1082 .B bind ^Z suspend main
1083 .RE
1084 .sp
1085 To make \fBShift+Alt+C\fR copy the marked region to the system's clipboard:
1086 .sp
1087 .RS
1088 .B bind Sh\-M\-C """{execute}| xsel \-ib {enter}{undo}""" main
1089 .RE
1090 .sp
1091
1092 .SH FILES
1093 .TP
1094 .I /etc/nanorc
1095 System-wide configuration file.
1096 .TP
1097 .IR ~/.nanorc " or " $XDG_CONFIG_HOME/nano/nanorc " or " ~/.config/nano/nanorc
1098 Per-user configuration file.
1099 .TP
1100 .I /usr/share/nano/*
1101 Syntax definitions for the syntax coloring of common file types
1102 (and for less common file types in the \fIextra/\fR subdirectory).
1103
1104 .SH SEE ALSO
1105 .BR nano (1)
1106 .TP
1107 .I https://nano\-editor.org/cheatsheet.html
1108 An overview of the default key bindings.