Debian Codegraph @

upstream/debian-trixie/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.4" "April 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 \fBnano\fR only reads and writes files inside \fIdirectory\fR and its
254 subdirectories. Also, the current directory is changed to here, so
255 files are inserted from this directory. By default, the operating
256 directory feature is turned off.
257 .TP
258 .B set positionlog
259 Save the cursor position of files between editing sessions.
260 The cursor position is remembered for the 200 most-recently edited files.
261 .TP
262 .B set preserve
263 Preserve the XOFF and XON sequences (\fB^S\fR and \fB^Q\fR) so that
264 they are caught by the terminal (stopping and resuming the output).
265 .TP
266 .B set promptcolor \fR[\fBbold,\fR][\fBitalic,\fR]\fIfgcolor\fB,\fIbgcolor\fR
267 Use this color combination for the prompt bar.
268 (When this option is not specified, the colors of the title bar are used.)
269 See \fBset \%titlecolor\fR for more details.
270 .TP
271 .BI "set punct """ characters """"
272 Set the characters treated as closing punctuation when justifying
273 paragraphs. This may not include blank characters. Only the
274 specified closing punctuation, optionally followed by closing brackets
275 (see \fBset brackets\fR), can end sentences. The default value is "\fB!.?\fR".
276 .TP
277 .B set quickblank
278 Make status-bar messages disappear after 1 keystroke instead of after 20.
279 Note that option \fBconstantshow\fR overrides this.
280 When option \fBminibar\fR or \fBzero\fR is in effect,
281 \fBquickblank\fR makes a message disappear after
282 0.8 seconds instead of after the default 1.5 seconds.
283 .TP
284 .BI "set quotestr """ regex """"
285 Set the regular expression for matching the quoting part of a line.
286 The default value is "\fB^([\ \et]*([!#%:;>|}]|//))+\fR".
287 (Note that \fB\et\fR stands for an actual Tab character.)
288 This makes it possible to rejustify blocks of quoted text when composing
289 email, and to rewrap blocks of line comments when writing source code.
290 .TP
291 .B set rawsequences
292 Interpret escape sequences directly, instead of asking \fBncurses\fR
293 to translate them. (If you need this option to get some keys to work
294 properly, it means that the \fBterminfo\fR terminal description that is used
295 does not fully match the actual behavior of your terminal. This can
296 happen when you ssh into a BSD machine, for example.)
297 Using this option disables \fBnano\fR's mouse support.
298 .TP
299 .B set rebinddelete
300 Interpret the Delete and Backspace keys differently so that both Backspace
301 and Delete work properly. You should only use this option when on your
302 system either Backspace acts like Delete or Delete acts like Backspace.
303 .TP
304 .B set regexp
305 Do regular-expression searches by default.
306 Regular expressions in \fBnano\fR are of the extended type (ERE).
307 .TP
308 .B set saveonexit
309 Save a changed buffer automatically on exit (\fB^X\fR); don't prompt.
310 .TP
311 .B set scrollercolor \fIfgcolor\fB,\fIbgcolor\fR
312 Use this color combination for the indicator alias "scrollbar".
313 See \fBset \%titlecolor\fR for more details.
314 .TP
315 .B set selectedcolor \fR[\fBbold,\fR][\fBitalic,\fR]\fIfgcolor\fB,\fIbgcolor\fR
316 Use this color combination for selected text.
317 See \fBset \%titlecolor\fR for more details.
318 .TP
319 .B set showcursor
320 Put the cursor on the highlighted item in the file browser, and show
321 the cursor in the help viewer, to aid braille users and people with
322 poor vision.
323 .TP
324 .B set smarthome
325 Make the Home key smarter. When Home is pressed anywhere but at the
326 very beginning of non-whitespace characters on a line, the cursor jumps
327 to that beginning (either forwards or backwards). If the cursor is
328 already at that position, it jumps to the true beginning of the line.
329 .TP
330 .B set softwrap
331 Display lines that exceed the screen's width over multiple screen lines.
332 (You can make this soft-wrapping occur at whitespace instead of rudely at
333 the screen's edge, by using also \fBset atblanks\fR.)
334 .TP
335 .B set speller """\fIprogram\fR [\fIargument \fR...]\fB"""
336 Use the given \fIprogram\fR to do spell checking and correcting, instead of
337 using the built-in corrector that calls \fBhunspell\fR(1) or \fBspell\fR(1).
338 .TP
339 .B set spotlightcolor \fR[\fBbold,\fR][\fBitalic,\fR]\fIfgcolor\fB,\fIbgcolor\fR
340 Use this color combination for highlighting a search match.
341 The default value is \fBblack,\%lightyellow\fR.
342 See \fBset \%titlecolor\fR for valid color names.
343 .TP
344 .B set stateflags
345 Use the top-right corner of the screen for showing some state flags:
346 \fBI\fR when auto-indenting, \fBM\fR when the mark is on, \fBL\fR when
347 hard-wrapping (breaking long lines), \fBR\fR when recording a macro,
348 and \fBS\fR when soft-wrapping.
349 When the buffer is modified, a star (\fB*\fR) is shown after the
350 filename in the center of the title bar.
351 .TP
352 .B set statuscolor \fR[\fBbold,\fR][\fBitalic,\fR]\fIfgcolor\fB,\fIbgcolor\fR
353 Use this color combination for the status bar.
354 See \fBset \%titlecolor\fR for more details.
355 .TP
356 .B set stripecolor \fR[\fBbold,\fR][\fBitalic,\fR]\fIfgcolor\fB,\fIbgcolor\fR
357 Use this color combination for the vertical guiding stripe.
358 See \fBset \%titlecolor\fR for more details.
359 .TP
360 .B set tabsize \fInumber\fR
361 Use a tab size of \fInumber\fR columns. The value of \fInumber\fR must be
362 greater than 0. The default value is \fB8\fR.
363 .TP
364 .B set tabstospaces
365 Convert each typed tab to spaces \(em to the number of spaces
366 that a tab at that position would take up.
367 (Note: pasted tabs are not converted.)
368 .TP
369 .B set titlecolor \fR[\fBbold,\fR][\fBitalic,\fR]\fIfgcolor\fB,\fIbgcolor\fR
370 Use this color combination for the title bar.
371 Valid names for the foreground and background colors are:
372 .BR red ", " green ", " blue ", " \%magenta ", " \%yellow ", " \%cyan ,
373 .BR white ", and " black .
374 Each of these eight names may be prefixed with the word \fBlight\fR
375 to get a brighter version of that color.
376 The word \fBgrey\fR or \fBgray\fR may be used
377 as a synonym for \fB\%lightblack\fR.
378 On a Linux console, \fBlight\fR does not have
379 any effect for a background color.
380 On terminal emulators that can do at least 256 colors,
381 other valid (but unprefixable) color names are:
382 .BR pink ", " \%purple ", " mauve ", " \%lagoon ", " mint ", " lime ", " peach ,
383 .BR \%orange ", " \%latte ", " \%rosy ", " beet ", " plum ", " sea ", " sky ,
384 .BR slate ", " teal ", " sage ", " brown ", " \%ocher ", " sand ", " \%tawny ,
385 .BR brick ", " \%crimson ", and " \%normal
386 \(em where \fB\%normal\fR means the default foreground or background color.
387 On such emulators, the color may also be specified as a three-digit hexadecimal
388 number prefixed with \fB#\fR, with the digits representing the amounts of red,
389 green, and blue, respectively. This tells \fBnano\fR to select from the
390 available palette the color that approximates the given values.
391
392 Either "\fIfgcolor\fR" or "\fB,\fIbgcolor\fR" may be left out,
393 and the pair may be preceded by \fBbold\fR and/or \fB\%italic\fR
394 (separated by commas) to get a bold and/or slanting typeface,
395 if your terminal can do those.
396 .TP
397 .B set trimblanks
398 Remove trailing whitespace from wrapped lines when automatic
399 hard-wrapping occurs or when text is justified.
400 .TP
401 .B set unix
402 Save a file by default in Unix format. This overrides nano's
403 default behavior of saving a file in the format that it had.
404 (This option has no effect when you also use \fBset noconvert\fR.)
405 .TP
406 .BI "set whitespace """ characters """"
407 Set the two characters used to indicate the presence of tabs and
408 spaces. They must be single-column characters. The default pair
409 for a UTF-8 locale is "\fB\[Fc]\[md]\fR", and for other locales "\fB>.\fR".
410 .TP
411 .B set wordbounds
412 Detect word boundaries differently by treating punctuation
413 characters as parts of words.
414 .TP
415 .BI "set wordchars """ characters """"
416 Specify which other characters (besides the normal alphanumeric ones)
417 should be considered as parts of words. When using this option, you
418 probably want to unset \fBwordbounds\fR.
419 .TP
420 .B set zap
421 Let an unmodified Backspace or Delete erase the marked region
422 (instead of a single character, and without affecting the cutbuffer).
423 .TP
424 .B set zero
425 Hide all elements of the interface (title bar, status bar, and help lines)
426 and use all rows of the terminal for showing the contents of the buffer.
427 The status bar appears only when there is a significant message,
428 and disappears after 1.5 seconds or upon the next keystroke.
429 With \fBM\-Z\fR the title bar plus status bar can be toggled.
430 With \fBM\-X\fR the help lines.
431
432 .SH SYNTAX HIGHLIGHTING
433 Coloring the different syntactic elements of a file
434 is done via regular expressions (see the \fBcolor\fR command below).
435 This is inherently imperfect, because regular expressions are not
436 powerful enough to fully parse a file. Nevertheless, regular
437 expressions can do a lot and are easy to make, so they are a
438 good fit for a small editor like \fBnano\fR.
439 .sp
440 All regular expressions in \fBnano\fR are POSIX extended regular expressions.
441 This means that \fB.\fR, \fB?\fR, \fB*\fR, \fB+\fR, \fB^\fR, \fB$\fR, and
442 several other characters are special.
443 The period \fB.\fR matches any single character,
444 \fB?\fR means the preceding item is optional,
445 \fB*\fR means the preceding item may be matched zero or more times,
446 \fB+\fR means the preceding item must be matched one or more times,
447 \fB^\fR matches the beginning of a line, and \fB$\fR the end,
448 \fB\e<\fR matches the start of a word, and \fB\e>\fR the end,
449 and \fB\es\fR matches a blank.
450 It also means that lookahead and lookbehind are not possible.
451 A complete explanation can be found in the manual page of GNU grep:
452 \fBman grep\fR.
453 .sp
454 Each regular expression in a \fBnanorc\fR file should be wrapped in
455 double quotes (\fB""\fR). Multiple regular expressions can follow
456 each other on a line by separating them with blanks. This means that
457 a regular expression cannot contain a double quote followed by a blank.
458 When you need this combination inside a regular expression,
459 then either the double quote or the blank should be put
460 between square brackets (\fB[]\fR).
461 .sp
462 For each kind of file a separate syntax can be defined
463 via the following commands:
464 .TP
465 .BI syntax " name \fR[" """" fileregex """ " \fR...]
466 Start the definition of a syntax with this \fIname\fR.
467 All subsequent \fBcolor\fR and other such commands
468 are added to this syntax, until a new \fBsyntax\fR
469 command is encountered.
470 .sp
471 When \fBnano\fR is run, this syntax is automatically
472 activated (for the relevant buffer) if the absolute filename
473 matches the extended regular expression \fIfileregex\fR.
474 Or the syntax can be explicitly activated (for all buffers)
475 by using the \fB\-Y\fR or \fB\-\-syntax\fR
476 command-line option followed by the \fIname\fR.
477 .sp
478 The syntax \fBdefault\fR is special: it takes no \fIfileregex\fR,
479 and applies to files that don't match any syntax's regexes.
480 The syntax \fBnone\fR is reserved; specifying it on the command line
481 is the same as not having a syntax at all.
482 .TP
483 .BI "header """ regex """ " \fR...
484 If from all defined syntaxes no \fIfileregex\fR matched, then compare
485 this \fIregex\fR (or regexes) against the first line of the current file,
486 to determine whether this syntax should be used for it.
487 .TP
488 .BI "magic """ regex """ " \fR...
489 If no \fIfileregex\fR matched and no \fBheader\fR regex matched
490 either, then compare this \fIregex\fR (or regexes) against the
491 result of querying the \fBmagic\fR database about the current
492 file, to determine whether this syntax should be used for it.
493 (This querying is done only when \fBlibmagic\fR is actually installed
494 on the system and \fB\-\-magic\fR or \fBset magic\fR was given.)
495 .TP
496 .BI formatter " program " \fR[ "argument " \fR...]
497 Run the given \fIprogram\fR on the full contents of the current buffer.
498 .TP
499 .BI linter " program " \fR[ "argument " \fR...]
500 Use the given \fIprogram\fR to run a syntax check on the current buffer.
501 .TP
502 .BI "comment """ string """"
503 Use the given \fIstring\fR for commenting and uncommenting lines.
504 If the string contains a vertical bar or pipe character (\fB|\fR),
505 this designates bracket-style comments; for example, "\fB/*|*/\fR" for
506 CSS files. The characters before the pipe are prepended to the line and the
507 characters after the pipe are appended at the end of the line. If no pipe
508 character is present, the full string is prepended; for example, "\fB#\fR"
509 for Python files. If empty double quotes are specified, the comment/uncomment
510 function is disabled; for example, "" for JSON.
511 The default value is "\fB#\fR".
512 .TP
513 .BI "tabgives """ string """"
514 Make the <Tab> key produce the given \fIstring\fR. Useful for languages like
515 Python that want to see only spaces for indentation.
516 This overrides the setting of the \fBtabstospaces\fR option.
517 .TP
518 .BI "color \fR[\fBbold,\fR][\fBitalic,\fR]" fgcolor , bgcolor " """ regex """ " \fR...
519 Paint all pieces of text that match the extended regular expression
520 \fIregex\fR with the given foreground and background colors, at least
521 one of which must be specified. Valid color names are:
522 .BR red ", " green ", " blue ", " \%magenta ", " \%yellow ", " \%cyan ,
523 .BR white ", and " black .
524 Each of these eight names may be prefixed with the word \fBlight\fR
525 to get a brighter version of that color.
526 The word \fBgrey\fR or \fBgray\fR may be used
527 as a synonym for \fB\%lightblack\fR.
528 On a Linux console, \fBlight\fR does not have
529 any effect for a background color.
530 On terminal emulators that can do at least 256 colors,
531 other valid (but unprefixable) color names are:
532 .BR pink ", " \%purple ", " mauve ", " \%lagoon ", " mint ", " lime ", " peach ,
533 .BR \%orange ", " \%latte ", " \%rosy ", " beet ", " plum ", " sea ", " sky ,
534 .BR slate ", " teal ", " sage ", " brown ", " \%ocher ", " sand ", " \%tawny ,
535 .BR brick ", " \%crimson ", and " \%normal
536 \(em where \fB\%normal\fR means the default foreground or background color.
537 On such emulators, the color may also be specified as a three-digit hexadecimal
538 number prefixed with \fB#\fR, with the digits representing the amounts of red,
539 green, and blue, respectively. This tells \fBnano\fR to select from the
540 available palette the color that approximates the given values.
541
542 The color pair may be preceded by \fBbold\fR and/or \fB\%italic\fR
543 (separated by commas) to get a bold and/or slanting typeface,
544 if your terminal can do those.
545 .sp
546 All coloring commands are applied in the order in which they are specified,
547 which means that later commands can recolor stuff that was colored earlier.
548 .TP
549 .BI "icolor \fR[\fBbold,\fR][\fBitalic,\fR]" fgcolor , bgcolor " """ regex """ " \fR...
550 Same as above, except that the matching is case insensitive.
551 .TP
552 .BI "color \fR[\fBbold,\fR][\fBitalic,\fR]" fgcolor , bgcolor " start=""" fromrx """ end=""" torx """"
553 Paint all pieces of text whose start matches extended regular expression
554 \fIfromrx\fR and whose end matches extended regular expression \fItorx\fR
555 with the given foreground and background colors,
556 at least one of which must be specified. This means that, after an
557 initial instance of \fIfromrx\fR, all text until the first instance of
558 \fItorx\fR is colored. This allows syntax highlighting to span
559 multiple lines.
560 .TP
561 .BI "icolor \fR[\fBbold,\fR][\fBitalic,\fR]" fgcolor , bgcolor " start=""" fromrx """ end=""" torx """"
562 Same as above, except that the matching is case insensitive.
563 .TP
564 .BI "include """ syntaxfile """"
565 Read in self-contained color syntaxes from \fIsyntaxfile\fR. Note that
566 \fIsyntaxfile\fR may contain only the above commands, from \fBsyntax\fR
567 to \fBicolor\fR.
568 .TP
569 .BI extendsyntax " name command argument " \fR...
570 Extend the syntax previously defined as \fIname\fR with another
571 \fI\%command\fR. This allows adding a new \fB\%color\fR, \fB\%icolor\fR,
572 \fB\%header\fR, \fB\%magic\fR, \fB\%formatter\fR, \fB\%linter\fR,
573 \fB\%comment\fR, or \fB\%tabgives\fR
574 command to an already defined syntax \(em useful when you want to
575 slightly improve a syntax defined in one of the system-installed
576 files (which normally are not writable).
577
578 .SH REBINDING KEYS
579 Key bindings can be changed via the following three commands:
580 .RS 3
581 .TP
582 .BI bind " key function menu"
583 Rebinds the given \fIkey\fR to the given \fIfunction\fR in the given \fImenu\fR
584 (or in all menus where the function exists when \fBall\fR is used).
585 .TP
586 .BI bind " key " """" string """" " menu"
587 Makes the given \fIkey\fR produce the given \fIstring\fR in the given
588 \fImenu\fR (or in all menus where the key exists when \fBall\fR is used).
589 Besides literal text and/or control codes, the \fIstring\fR may contain
590 function names between braces. These functions are invoked when
591 the key is typed. To include a literal opening brace, use \fB{{}\fR.
592 .TP
593 .BI unbind " key menu"
594 Unbinds the given \fIkey\fR from the given \fImenu\fR (or from all
595 menus where the key exists when \fBall\fR is used).
596 .RE
597 .sp
598 Note that \fBbind \fIkey\fR \fB"{\fIfunction\fB}"\fR \fImenu\fR is equivalent
599 to \fBbind \fIkey\fR \fIfunction\fR \fImenu\fR, except that for the latter form
600 \fBnano\fR checks the availability of the \fIfunction\fR in the given \fImenu\fR
601 at startup time (and reports an error if it does not exist there), whereas for the
602 first form \fBnano\fR checks at execution time that the \fIfunction\fR exists
603 but not whether it makes any sense in the current menu. The user has to take care
604 that a function name between braces (or any sequence of them) is appropriate.
605 Strange behavior or even a crash can result when the braced name is unfitting.
606
607 .TP
608 The format of \fIkey\fR should be one of:
609 .RS 3
610 .TP 7
611 .BI ^ X
612 where \fIX\fR is a Latin letter, or one of several ASCII characters
613 (@, ], \e, ^, _), or the word "Space".
614 Example: ^C.
615 .TP
616 .BI M\- X
617 where \fIX\fR is any ASCII character except [, or the word "Space".
618 Example: M\-8.
619 .TP
620 .BI Sh\-M\- X
621 where \fIX\fR is a Latin letter.
622 Example: Sh\-M\-U.
623 By default, each Meta+letter keystroke does the same as the corresponding
624 Shift+Meta+letter. But when any Shift+Meta bind is made, that will
625 no longer be the case, for all letters.
626 .TP
627 .BI F N
628 where \fIN\fR is a numeric value from 1 to 24.
629 Example: F10.
630 (Often, \fBF13\fR to \fBF24\fR can be typed as \fBF1\fR to \fBF12\fR with Shift.)
631 .TP
632 .BR Ins " or " Del .
633 .RE
634 .sp
635 Rebinding \fB^M\fR (Enter) or \fB^I\fR (Tab) is probably not a good idea.
636 Rebinding \fB^[\fR (Esc) is not possible, because its keycode
637 is the starter byte of Meta keystrokes and escape sequences.
638 Rebinding any of the dedicated cursor-moving keys (the arrows,
639 Home, End, PageUp and PageDown) is not possible.
640 On some terminals it's not possible to rebind \fB^H\fR (unless \fB\-\-raw\fR
641 is used) because its keycode is identical to that of the Backspace key.
642
643 .TP
644 Valid \fIfunction\fR names to be bound are:
645 .RS 3
646 .TP 2
647 .B help
648 Invokes the help viewer.
649 .TP
650 .B cancel
651 Cancels the current command.
652 .TP
653 .B exit
654 Exits from the program (or from the help viewer or file browser).
655 .TP
656 .B writeout
657 Writes the current buffer to disk, asking for a name.
658 .TP
659 .B savefile
660 Writes the current file to disk without prompting.
661 .TP
662 .B insert
663 Inserts a file into the current buffer (at the current cursor position),
664 or into a new buffer when option \fBmultibuffer\fR is set.
665 .TP
666 .B whereis
667 Starts a forward search for text in the current buffer \(em or for filenames
668 matching a string in the current list in the file browser.
669 .TP
670 .B wherewas
671 Starts a backward search for text in the current buffer \(em or for filenames
672 matching a string in the current list in the file browser.
673 .TP
674 .B findprevious
675 Searches the next occurrence in the backward direction.
676 .TP
677 .B findnext
678 Searches the next occurrence in the forward direction.
679 .TP
680 .B replace
681 Interactively replaces text within the current buffer.
682 .TP
683 .B cut
684 Cuts and stores the current line (or the marked region).
685 .TP
686 .B copy
687 Copies the current line (or the marked region) without deleting it.
688 .TP
689 .B paste
690 Pastes the currently stored text into the current buffer at the
691 current cursor position.
692 .TP
693 .B zap
694 Throws away the current line (or the marked region).
695 (This function is bound by default to <Meta+Delete>.)
696 .TP
697 .B chopwordleft
698 Deletes from the cursor position to the beginning of the preceding word.
699 (This function is bound by default to <Shift+Ctrl+Delete>. If your terminal
700 produces \fB^H\fR for <Ctrl+Backspace>, you can make <Ctrl+Backspace> delete
701 the word to the left of the cursor by rebinding \fB^H\fR to this function.)
702 .TP
703 .B chopwordright
704 Deletes from the cursor position to the beginning of the next word.
705 (This function is bound by default to <Ctrl+Delete>.)
706 .TP
707 .B cutrestoffile
708 Cuts all text from the cursor position till the end of the buffer.
709 .TP
710 .B mark
711 Sets the mark at the current position, to start selecting text.
712 Or, when it is set, unsets the mark.
713 .TP
714 .B location
715 Reports the current position of the cursor in the buffer:
716 the line, column, and character positions.
717 .TP
718 .B wordcount
719 Counts and reports on the status bar the number of lines, words,
720 and characters in the current buffer (or in the marked region).
721 .TP
722 .B execute
723 Prompts for a program to execute. The program's output is inserted
724 into the current buffer (or into a new buffer when \fBM\-F\fR is toggled).
725 .TP
726 .B speller
727 Invokes a spell-checking program, either the default \fBhunspell\fR(1) or GNU
728 \fBspell\fR(1), or the one defined by \fB\-\-speller\fR or \fBset speller\fR.
729 .TP
730 .B formatter
731 Invokes a full-buffer-processing program (if the active syntax defines one).
732 (The current buffer is written out to a temporary file, the program
733 is run on it, and then the temporary file is read back in, replacing
734 the contents of the buffer.)
735 .TP
736 .B linter
737 Invokes a syntax-checking program (if the active syntax defines one).
738 If this program produces lines of the form "filename:linenum:charnum:
739 some message", then the cursor is put at the indicated position
740 in the mentioned file while showing "some message" on the status bar.
741 You can move from message to message with <PgUp> and <PgDn>,
742 and leave linting mode with \fB^C\fR or <Enter>.
743 .TP
744 .B justify
745 Justifies the current paragraph (or the marked region).
746 A paragraph is a group of contiguous lines that, apart from possibly
747 the first line, all have the same indentation. The beginning of a
748 paragraph is detected by either this lone line with a differing
749 indentation or by a preceding blank line.
750 .TP
751 .B fulljustify
752 Justifies the entire current buffer (or the marked region).
753 .TP
754 .B indent
755 Indents (shifts to the right) the current line or the marked lines.
756 .TP
757 .B unindent
758 Unindents (shifts to the left) the current line or the marked lines.
759 .TP
760 .B comment
761 Comments or uncomments the current line or the marked lines,
762 using the comment style specified in the active syntax.
763 .TP
764 .B complete
765 Completes (when possible) the fragment before the cursor
766 to a full word found elsewhere in the current buffer.
767 .TP
768 .B left
769 Goes left one position (in the editor or browser).
770 .TP
771 .B right
772 Goes right one position (in the editor or browser).
773 .TP
774 .B up
775 Goes one line up (in the editor or browser).
776 .TP
777 .B down
778 Goes one line down (in the editor or browser).
779 .TP
780 .B scrollup
781 Scrolls the viewport up one row (meaning that the text slides down)
782 while keeping the cursor in the same text position, if possible.
783 (This function is bound by default to <Alt+Up>.
784 If <Alt+Up> does nothing on your Linux console, see the FAQ:
785 .UR https://nano\-editor.org/dist/latest/faq.html#4.1
786 .UE .)
787 .TP
788 .B scrolldown
789 Scrolls the viewport down one row (meaning that the text slides up)
790 while keeping the cursor in the same text position, if possible.
791 (This function is bound by default to <Alt+Down>.)
792 .TP
793 .B center
794 Scrolls the line with the cursor to the middle of the viewport.
795 .TP
796 .B cycle
797 Scrolls the line with the cursor first to the middle of the viewport,
798 then to the top, then to the bottom.
799 .TP
800 .B prevword
801 Moves the cursor to the beginning of the previous word.
802 .TP
803 .B nextword
804 Moves the cursor to the beginning of the next word.
805 .TP
806 .B home
807 Moves the cursor to the beginning of the current line.
808 .TP
809 .B end
810 Moves the cursor to the end of the current line.
811 .TP
812 .B beginpara
813 Moves the cursor to the beginning of the current paragraph.
814 .TP
815 .B endpara
816 Moves the cursor to the end of the current paragraph.
817 .TP
818 .B prevblock
819 Moves the cursor to the beginning of the current or preceding block of text.
820 (Blocks are separated by one or more blank lines.)
821 .TP
822 .B nextblock
823 Moves the cursor to the beginning of the next block of text.
824 .TP
825 .B toprow
826 Moves the cursor to the first row in the viewport.
827 .TP
828 .B bottomrow
829 Moves the cursor to the last row in the viewport.
830 .TP
831 .B pageup
832 Goes up one screenful.
833 .TP
834 .B pagedown
835 Goes down one screenful.
836 .TP
837 .B firstline
838 Goes to the first line of the file.
839 .TP
840 .B lastline
841 Goes to the last line of the file.
842 .TP
843 .B gotoline
844 Goes to a specific line (and column if specified). Negative numbers count
845 from the end of the file (and end of the line).
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.