nano.1 (21371B)
1 .\" Copyright (C) 1999-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 NANO 1 "version 8.5" "June 2025" 20 21 .SH NAME 22 nano \- Nano's ANOther text editor, inspired by Pico 23 24 .SH SYNOPSIS 25 .B nano 26 .RI [ options "] [[\fB+" line [\fB, column "]] " file ]... 27 .sp 28 .BR nano " [" \fIoptions "] [[" + [ crCR ]{ / | ? } \fIstring "] " \fIfile ]... 29 30 .SH NOTICE 31 Since version 8.0, to be newcomer friendly, \fB^F\fR starts a forward search, 32 \fB^B\fR starts a backward search, \fBM\-F\fR searches the next occurrence 33 forward, and \fBM\-B\fR searches the next occurrence backward. If you want 34 those keystrokes to do what they did before version 8.0, add the following 35 lines at the end of your \fInanorc\fR file: 36 .sp 37 .RS 4 38 .B bind ^F forward main 39 .br 40 .B bind ^B back main 41 .br 42 .B bind M\-F formatter main 43 .br 44 .B bind M\-B linter main 45 .RE 46 .sp 47 48 .SH DESCRIPTION 49 \fBnano\fR is a small and friendly text editor. It copies the look and feel 50 of Pico, but is free software, and implements several features that Pico 51 lacks, such as: opening multiple files, scrolling per line, undo/redo, 52 syntax coloring, line numbering, and soft-wrapping overlong lines. 53 .sp 54 When giving a filename on the command line, the cursor can be put on a 55 specific line by adding the line number with a plus sign (\fB+\fR) before 56 the filename, and even in a specific column by adding it with a comma. 57 Negative numbers count from the end of the file or line. 58 .sp 59 The cursor can be put on the first or last occurrence of a specific string 60 by specifying that string after \fB+/\fR or \fB+?\fR before the filename. 61 The string can be made case sensitive and/or caused to be interpreted as a 62 regular expression by inserting \fBc\fR and/or \fBr\fR after the \fB+\fR sign. 63 These search modes can be explicitly disabled by using the uppercase variant 64 of those letters: \fBC\fR and/or \fBR\fR. When the string contains spaces, 65 it needs to be enclosed in quotes. To give an example: to open a file at 66 the first occurrence of the word "Foo", you would do: 67 .sp 68 .RS 4 69 .BI "nano +c/Foo " file 70 .RE 71 .sp 72 As a special case: if instead of a filename a dash (\fB\-\fR) is given, 73 \fBnano\fR will read data from standard input. 74 75 .SH EDITING 76 Entering text and moving around in a file is straightforward: typing the 77 letters and using the normal cursor movement keys. Commands are entered 78 by using the Control (^) and the Alt or Meta (M\-) keys. 79 Typing \fB^K\fR deletes the current line and puts it in the cutbuffer. 80 Consecutive \fB^K\fRs put all deleted lines together in the cutbuffer. 81 Any cursor movement or executing any other command causes the next 82 \fB^K\fR to overwrite the cutbuffer. A \fB^U\fR pastes the current 83 contents of the cutbuffer at the current cursor position. 84 .sp 85 When a more precise piece of text needs to be cut or copied, you can mark 86 its start with \fB^6\fR, move the cursor to its end (the marked text is 87 highlighted), and then use \fB^K\fR to cut it, or \fBM\-6\fR to copy it to 88 the cutbuffer. You can also save the marked text to a file with \fB^O\fR, 89 or spell check it with \fB^T^T\fR. 90 .sp 91 On some terminals, text can be selected also by holding down Shift while 92 using the arrow keys. Holding down the Ctrl or Alt key too increases 93 the stride. 94 Any cursor movement without Shift being held cancels such a selection. 95 .sp 96 Any valid Unicode code point can be inserted into the buffer by typing 97 \fBM\-V\fR followed by the hexadecimal digits of the code point (concluded 98 with \fB<Space>\fR or \fB<Enter>\fR when it are fewer than six digits). 99 A literal control code (except \fB^J\fR) can be inserted by typing 100 \fBM\-V\fR followed by the pertinent keystroke. 101 .sp 102 The two lines at the bottom of the screen show some important commands; 103 the built-in help (\fB^G\fR) lists all the available ones. 104 The default key bindings can be changed via a \fInanorc\fR file \(em see 105 .BR nanorc (5). 106 107 .\" Never hyphenate these: 108 .hw ncurses terminfo 109 110 .SH OPTIONS 111 .TP 112 .BR \-A ", " \-\-smarthome 113 Make the Home key smarter. When Home is pressed anywhere but at the 114 very beginning of non-whitespace characters on a line, the cursor jumps 115 to that beginning (either forwards or backwards). If the cursor is 116 already at that position, it jumps to the true beginning of the line. 117 .TP 118 .BR \-B ", " \-\-backup 119 When saving a file, back up the previous version of it, using the current 120 filename suffixed with a tilde (\fB~\fR). 121 .TP 122 .BI \-C " directory\fR, " \-\-backupdir= directory 123 Make and keep not just one backup file, but make and keep a uniquely numbered 124 one every time a file is saved \(em when backups are enabled (\fB\-B\fR). 125 The uniquely numbered files are stored in the specified \fIdirectory\fR. 126 .TP 127 .BR \-D ", " \-\-boldtext 128 For the interface, use bold instead of reverse video. 129 This can be overridden for specific elements by setting the options 130 \fB\%titlecolor\fR, \fB\%statuscolor\fR, \fB\%promptcolor\fR, 131 \fB\%minicolor\fR, \fB\%keycolor\fR, \fB\%numbercolor\fR, and/or 132 \fB\%selectedcolor\fR in your nanorc file. See \fBnanorc\fR(5). 133 .TP 134 .BR \-E ", " \-\-tabstospaces 135 Convert each typed tab to spaces \(em to the number of spaces 136 that a tab at that position would take up. 137 (Note: pasted tabs are not converted.) 138 .TP 139 .BR \-F ", " \-\-multibuffer 140 Read a file into a new buffer by default. 141 .TP 142 .BR \-G ", " \-\-locking 143 Use vim-style file locking when editing files. 144 .TP 145 .BR \-H ", " \-\-historylog 146 Save the last hundred search strings and replacement strings and 147 executed commands, so they can be easily reused in later sessions. 148 .TP 149 .BR \-I ", " \-\-ignorercfiles 150 Don't look at the system's \fInanorc\fR nor at the user's \fInanorc\fR. 151 .TP 152 .BI \-J " number\fR, " \-\-guidestripe= number 153 Draw a vertical stripe at the given column, to help judge the width of the 154 text. (The color of the stripe can be changed with \fBset \%stripecolor\fR 155 in your \fInanorc\fR file.) 156 .TP 157 .BR \-K ", " \-\-rawsequences 158 Interpret escape sequences directly, instead of asking \fBncurses\fR 159 to translate them. (If you need this option to get some keys to work 160 properly, it means that the \fBterminfo\fR terminal description that 161 is used does not fully match the actual behavior of your terminal. 162 This can happen when you ssh into a BSD machine, for example.) 163 Using this option disables \fBnano\fR's mouse support. 164 .TP 165 .BR \-L ", " \-\-nonewlines 166 Don't automatically add a newline when a text does not end with one. 167 (This can cause you to save non-POSIX text files.) 168 .TP 169 .BR \-M ", " \-\-trimblanks 170 Snip trailing whitespace from the wrapped line when automatic 171 hard-wrapping occurs or when text is justified. 172 .TP 173 .BR \-N ", " \-\-noconvert 174 Disable automatic conversion of files from DOS/Mac format. 175 .TP 176 .BR \-O ", " \-\-bookstyle 177 When justifying, treat any line that starts with whitespace as the 178 beginning of a paragraph (unless auto-indenting is on). 179 .TP 180 .BR \-P ", " \-\-positionlog 181 For the 200 most recent files, log the last position of the cursor, 182 and place it at that position again upon reopening such a file. 183 Also save and restore the positions of any anchors. 184 .TP 185 .BI "\-Q """ regex\fB"\fR, " \-\-quotestr=""" regex """" 186 Set the regular expression for matching the quoting part of a line. 187 The default value is "\fB^([\ \\t]*([!#%:;>|}]|//))+\fR". 188 (Note that \fB\\t\fR stands for an actual Tab.) 189 This makes it possible to rejustify blocks of quoted text when composing 190 email, and to rewrap blocks of line comments when writing source code. 191 .TP 192 .BR \-R ", " \-\-restricted 193 Restricted mode: don't read or write to any file not specified on the 194 command line. This means: don't read or write history files; 195 don't allow suspending; don't allow spell checking; 196 don't allow a file to be appended to, prepended to, or saved under a 197 different name if it already has one; and don't make backup files. 198 Restricted mode can also be activated by invoking \fBnano\fR 199 with any name beginning with 'r' (e.g.\& "rnano"). 200 .TP 201 .BR \-S ", " \-\-softwrap 202 Display over multiple screen rows lines that exceed the screen's width. 203 (You can make this soft-wrapping occur at whitespace instead of rudely at 204 the screen's edge, by using also \fB\-\-atblanks\fR.) 205 .TP 206 .BI \-T " number\fR, " \-\-tabsize= number 207 Set the size (width) of a tab to \fInumber\fR columns. The value of 208 \fInumber\fR must be greater than 0. The default value is \fB8\fR. 209 .TP 210 .BR \-U ", " \-\-quickblank 211 Make status-bar messages disappear after 1 keystroke instead of after 20. 212 Note that option \fB\-c\fR (\fB\-\-constantshow\fR) overrides this. 213 When option \fB\-\-minibar\fR or \fB\-\-zero\fR is in effect, 214 \fB\-\-quickblank\fR makes a message disappear after 215 0.8 seconds instead of after the default 1.5 seconds. 216 . 217 .TP 218 .BR \-V ", " \-\-version 219 Show the current version number and exit. 220 .TP 221 .BR \-W ", " \-\-wordbounds 222 Detect word boundaries differently by treating punctuation 223 characters as part of a word. 224 .TP 225 .BI "\-X """ characters\fB"\fR, " \-\-wordchars=""" characters """" 226 Specify which other characters (besides the normal alphanumeric ones) 227 should be considered as part of a word. When using this option, you 228 probably want to omit \fB\-W\fR (\fB\-\-wordbounds\fR). 229 .TP 230 .BI \-Y " name\fR, " \-\-syntax= name 231 Specify the name of the syntax highlighting to use from among the ones 232 defined in the \fInanorc\fR files. 233 .TP 234 .BR \-Z ", " \-\-zap 235 Let an unmodified Backspace or Delete erase the marked region 236 (instead of a single character, and without affecting the cutbuffer). 237 .TP 238 .BR \-a ", " \-\-atblanks 239 When doing soft line wrapping, wrap lines at whitespace 240 instead of always at the edge of the screen. 241 .TP 242 .BR \-b ", " \-\-breaklonglines 243 Automatically hard-wrap the current line when it becomes overlong. 244 (This option is the opposite of \fB\-w\fR (\fB\-\-nowrap\fR) -- 245 the last one given takes effect.) 246 .TP 247 .BR \-c ", " \-\-constantshow 248 Constantly report the cursor position on the status bar. 249 Note that this overrides option \fB\-U\fR (\fB\-\-quickblank\fR). 250 .TP 251 .BR \-d ", " \-\-rebinddelete 252 Interpret the Delete and Backspace keys differently so that both Backspace 253 and Delete work properly. You should only use this option when on your 254 system either Backspace acts like Delete or Delete acts like Backspace. 255 .TP 256 .BR \-e ", " \-\-emptyline 257 Do not use the line below the title bar, leaving it entirely blank. 258 .TP 259 .BI \-f " file\fR, " \-\-rcfile= file 260 Read only this \fIfile\fR for setting nano's options, instead of reading 261 both the system-wide and the user's nanorc files. 262 .TP 263 .BR \-g ", " \-\-showcursor 264 Make the cursor visible in the file browser (putting it on the 265 highlighted item) and in the help viewer. Useful for braille users 266 and people with poor vision. 267 .TP 268 .BR \-h ", " \-\-help 269 Show a summary of the available command-line options and exit. 270 .TP 271 .BR \-i ", " \-\-autoindent 272 Automatically indent a newly created line to the same number of tabs 273 and/or spaces as the previous line (or as the next line if the previous 274 line is the beginning of a paragraph). 275 .TP 276 .BR \-j ", " \-\-jumpyscrolling 277 Scroll the buffer contents per half-screen instead of per line. 278 .TP 279 .BR \-k ", " \-\-cutfromcursor 280 Make the 'Cut Text' command (normally \fB^K\fR) cut from the current cursor 281 position to the end of the line, instead of cutting the entire line. 282 .TP 283 .BR \-l ", " \-\-linenumbers 284 Display line numbers to the left of the text area. 285 (Any line with an anchor additionally gets a mark in the margin.) 286 .TP 287 .BR \-m ", " \-\-mouse 288 Enable mouse support, if available for your system. When enabled, mouse 289 clicks can be used to place the cursor, set the mark (with a double 290 click), and execute shortcuts. The mouse works in the X Window 291 System, and on the console when gpm is running. Text can still be 292 selected through dragging by holding down the Shift key. 293 .TP 294 .BR \-n ", " \-\-noread 295 Treat any name given on the command line as a new file. This allows 296 \fBnano\fR to write to named pipes: it starts with a blank buffer, 297 and writes to the pipe when the user saves the "file". This way 298 \fBnano\fR can be used as an editor in combination with for instance 299 \fBgpg\fR without having to write sensitive data to disk first. 300 .TP 301 .BI \-o " directory\fR, " \-\-operatingdir= directory 302 Change to the given \fIdirectory\fR, and allow reading and writing 303 files only in this directory and its subdirectories. 304 .TP 305 .BR \-p ", " \-\-preserve 306 Preserve the XOFF and XON sequences (\fB^S\fR and \fB^Q\fR) so that 307 they are caught by the terminal (stopping and resuming the output). 308 Note that option \fB\-/\fR (\fB\-\-modernbindings\fR) overrides this. 309 .TP 310 .BR \-q ", " \-\-indicator 311 Display a "scrollbar" on the righthand side of the edit window. 312 It shows the position of the viewport in the buffer 313 and how much of the buffer is covered by the viewport. 314 .TP 315 .BI \-r " number\fR, " \-\-fill= number 316 Set the target width for justifying and automatic hard-wrapping at this 317 \fInumber\fR of columns. If the value is 0 or less, wrapping occurs 318 at the width of the screen minus \fInumber\fR columns, allowing the wrap 319 point to vary along with the width of the screen if the screen is resized. 320 The default value is \fB\-8\fR. 321 .TP 322 .B "\-s ""\fIprogram\fR [\fIargument \fR...]\fB""\fR, \fB\-\-speller=""\fIprogram\fR [\fIargument \fR...]\fB""" 323 Use this command to perform spell checking and correcting, instead of 324 using the built-in corrector that calls \fBhunspell\fR(1) or \fBspell\fR(1). 325 .TP 326 .BR \-t ", " \-\-saveonexit 327 Save a changed buffer without prompting (when exiting with \fB^X\fR). 328 .TP 329 .BR \-u ", " \-\-unix 330 Save a file by default in Unix format. This overrides nano's 331 default behavior of saving a file in the format that it had. 332 (This option has no effect when you also use \fB\-\-noconvert\fR.) 333 .TP 334 .BR \-v ", " \-\-view 335 Just view the file and disallow editing: read-only mode. 336 This mode allows the user to open also other files for viewing, 337 unless \fB\-\-restricted\fR is given too. 338 .TP 339 .BR \-w ", " \-\-nowrap 340 Do not automatically hard-wrap the current line when it becomes overlong. 341 This is the default. (This option is the opposite of \fB\-b\fR 342 (\fB\-\-breaklonglines\fR) \(em the last one given takes effect.) 343 .TP 344 .BR \-x ", " \-\-nohelp 345 Don't show the two help lines at the bottom of the screen. 346 .TP 347 .BR \-y ", " \-\-afterends 348 Make Ctrl+Right and Ctrl+Delete stop at word ends instead of beginnings. 349 .TP 350 .BR \-z ", " \-\-listsyntaxes 351 List the names of the available syntaxes and exit. 352 .TP 353 .BR \-! ", " \-\-magic 354 When neither the file's name nor its first line give a clue, 355 try using libmagic to determine the applicable syntax. 356 .TP 357 .BR \-@ ", " \-\-colonparsing 358 When a filename given on the command line ends in a colon plus digits 359 and this filename does not exist, then snip the colon plus digits and 360 understand the digits as a line number. If the trimmed filename does 361 not exist either, then repeat the process and understand the obtained 362 two numbers as line and column number. But if the doubly trimmed 363 filename does not exist either, then forget the trimming and accept 364 the original filename as is. To disable this colon parsing for some 365 file, use \fB+1\fR or similar before the relevant filename. 366 .TP 367 .BR \-% ", " \-\-stateflags 368 Use the top-right corner of the screen for showing some state flags: 369 \fBI\fR when auto-indenting, \fBM\fR when the mark is on, \fBL\fR when 370 hard-wrapping (breaking long lines), \fBR\fR when recording a macro, 371 and \fBS\fR when soft-wrapping. 372 When the buffer is modified, a star (\fB*\fR) is shown after the 373 filename in the center of the title bar. 374 .TP 375 .BR \-_ ", " \-\-minibar 376 Suppress the title bar and instead show information about 377 the current buffer at the bottom of the screen, in the space 378 for the status bar. In this "mini bar" the filename is shown 379 on the left, followed by an asterisk if the buffer has been modified. 380 On the right are displayed the current line and column number, the 381 code of the character under the cursor (in Unicode format: U+xxxx), 382 the same flags as are shown by \fB\-\-stateflags\fR, and a percentage 383 that expresses how far the cursor is into the file (linewise). 384 When a file is loaded or saved, and also when switching between buffers, 385 the number of lines in the buffer is displayed after the filename. 386 This number is cleared upon the next keystroke, or replaced with an 387 [i/n] counter when multiple buffers are open. 388 The line plus column numbers and the character code are displayed only when 389 \fB\-\-constantshow\fR is used, and can be toggled on and off with \fBM\-C\fR. 390 The state flags are displayed only when \fB\-\-stateflags\fR is used. 391 .TP 392 .BR \-0 ", " \-\-zero 393 Hide all elements of the interface (title bar, status bar, and help lines) 394 and use all rows of the terminal for showing the contents of the buffer. 395 The status bar appears only when there is a significant message, 396 and disappears after 1.5 seconds or upon the next keystroke. 397 With \fBM\-Z\fR the title bar plus status bar can be toggled. 398 With \fBM\-X\fR the help lines. 399 .TP 400 .BR \-/ ", " \-\-modernbindings 401 Use key bindings similar to the ones that most modern programs use: 402 \fB^X\fR cuts, \fB^C\fR copies, \fB^V\fR pastes, 403 \fB^Z\fR undoes, \fB^Y\fR redoes, 404 \fB^F\fR searches forward, \fB^G\fR searches next, 405 \fB^S\fR saves, \fB^O\fR opens a file, \fB^Q\fR quits, 406 and (when the terminal permits) \fB^H\fR shows help. 407 Furthermore, \fB^A\fR sets the mark, 408 \fB^R\fR makes replacements, \fB^D\fR searches previous, 409 \fB^P\fR shows the position, \fB^T\fR goes to a line, 410 \fB^W\fR writes out a file, and \fB^E\fR executes a command. 411 Note that this overrides option \fB\-p\fR (\fB\-\-preserve\fR). 412 413 .SH TOGGLES 414 Several of the above options can be switched on and off also while 415 \fBnano\fR is running. For example, \fBM\-L\fR toggles the 416 hard-wrapping of long lines, \fBM\-S\fR toggles soft-wrapping, 417 \fBM\-N\fR toggles line numbers, \fBM\-M\fR toggles the mouse, 418 \fBM\-I\fR auto-indentation, and \fBM\-X\fR the help lines. 419 See at the end of the \fB^G\fR help text for a complete list. 420 .sp 421 The \fBM\-X\fR toggle is special: it works in all menus except 422 the help viewer and the linter. All other toggles work in 423 the main menu only. 424 425 .SH FILES 426 When \fB\-\-rcfile\fR is given, \fBnano\fR reads just the specified file 427 for setting its options and syntaxes and key bindings. Without that 428 option, \fBnano\fR reads two configuration files: first the system's 429 \fInanorc\fR (if it exists), and then the user's \fInanorc\fR (if it 430 exists), either \fI~/.nanorc\fR or \fI$XDG_CONFIG_HOME/nano/nanorc\fR 431 or \fI~/.config/nano/nanorc\fR, whichever is encountered first. See 432 .BR nanorc (5) 433 for more information on the possible contents of those files. 434 .sp 435 See \fI/usr/share/nano/\fR and \fI/usr/share/nano/extra/\fR 436 for available syntax-coloring definitions. 437 438 .SH NOTES 439 Suspension is enabled by default, reachable via \fB^T^Z\fR. 440 (If you want a plain \fB^Z\fR to suspend nano, add 441 \fBbind ^Z suspend main\fR to your nanorc.) 442 .sp 443 At a Yes-No prompt, \fB^Y\fR can be used for "Yes", \fB^N\fR for "No", 444 and \fB^A\fR for "All". These unlisted bindings work in any locale. 445 .sp 446 When you want to copy marked text from \fBnano\fR to the system's clipboard, 447 see one of the examples in the \fBnanorc\fR(5) man page. 448 .sp 449 If no alternative spell checker command is specified on the command 450 line nor in one of the \fInanorc\fR files, \fBnano\fR checks the 451 \fBSPELL\fR environment variable for one. 452 .sp 453 In some cases \fBnano\fR tries to dump the buffer into an emergency file. 454 This happens mainly if \fBnano\fR receives a SIGHUP or SIGTERM or runs out 455 of memory. It writes the buffer into a file named \fInano.save\fR if the 456 buffer didn't have a name already, or adds a ".save" suffix to the current 457 filename. If an emergency file with that name already exists in the 458 current directory, it adds ".save" plus a number (e.g.\& ".save.1") to 459 the current filename in order to make it unique. In multibuffer mode, 460 \fBnano\fR writes all open buffers to their respective emergency files. 461 .sp 462 If you have any question about how to use \fBnano\fR in some specific 463 situation, you can ask on \fIhelp\-nano@gnu.org\fR. 464 465 .SH BUGS 466 The recording and playback of keyboard macros works correctly only on a 467 terminal emulator, not on a Linux console (VT), because the latter does 468 not by default distinguish modified from unmodified arrow keys. 469 .sp 470 Please report any other bugs that you encounter via: 471 .br 472 .IR https://savannah.gnu.org/bugs/?group=nano . 473 .sp 474 When nano crashes, it saves any modified buffers to emergency .save files. 475 If you are able to reproduce the crash and you want to get a backtrace, define 476 the environment variable \fBNANO_NOCATCH\fR. 477 478 .SH HOMEPAGE 479 .I https://nano\-editor.org/ 480 481 .SH SEE ALSO 482 .BR nanorc (5) 483 .sp 484 \fI/usr/share/doc/nano/\fR (or equivalent on your system)