nano/doc/nano.texi

1822 lines
62 KiB
Plaintext
Raw Normal View History

\input texinfo @c -*-texinfo-*-
@c %**start of header
@setfilename nano.info
@settitle nano
@c %**end of header
@documentencoding UTF-8
@smallbook
@set EDITION 0.5
@set VERSION 4.7
@set UPDATED December 2019
@dircategory Editors
@direntry
* nano: (nano). Small and friendly text editor.
@end direntry
@c tex
@c \overfullrule=0pt
@c end tex
@titlepage
@title GNU @command{nano}
@subtitle a small and friendly text editor
@subtitle version 4.7
@author Chris Allegretta
@page
This manual documents the GNU @command{nano} editor.
@sp 1
This manual is part of the GNU @command{nano} distribution.@*
@sp 4
Copyright @copyright{} 1999-2009, 2014-2020 Free Software Foundation, Inc.
@sp 1
This document is dual-licensed. You may distribute and/or modify it
under the terms of either of the following licenses:
@sp 1
* The GNU General Public License, as published by the Free Software
Foundation, version 3 or (at your option) any later version. You
should have received a copy of the GNU General Public License along
with this program. If not, see @url{https://www.gnu.org/licenses/}.
@sp 1
* The GNU Free Documentation License, as published by the Free Software
Foundation, version 1.2 or (at your option) any later version, with no
Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
You should have received a copy of the GNU Free Documentation License
along with this program. If not, see @url{https://www.gnu.org/licenses/}.
@sp 1
You may contact the author by
e-mail: @email{chrisa@@asty.org}@*
@end titlepage
@ifnottex
@node Top
@top
This manual documents the GNU @command{nano} editor, version 4.7.
@menu
* Introduction::
* Invoking::
* Command-line Options::
* Editor Basics::
* Built-in Help::
* Feature Toggles::
* Nanorc Files::
* The File Browser::
* Pico Compatibility::
* Building and Configure Options::
@end menu
@end ifnottex
@node Introduction
@chapter Introduction
GNU @command{nano} is a small and friendly text editor. Besides
basic text editing, @command{nano} offers features like undo/redo,
syntax coloring, interactive search-and-replace, auto-indentation,
line numbers, word completion, file locking, backup files, and
internationalization support.
The original goal for @command{nano} was to be a complete bug-for-bug
emulation of Pico. But currently the goal is to be as compatible
as is reasonable while offering a superset of Pico's functionality.
@xref{Pico Compatibility} for more details on how @command{nano} and
Pico differ.
Starting with version 4.0, @command{nano} no longer hard-wraps an overlong
line by default. It further uses smooth scrolling by default, and by
default includes the line below the title bar into the editing area.
If you want the old, Pico behavior back, you can use the
following options: @option{--breaklonglines},
@option{--jumpyscrolling}, and @option{--emptyline}
(or @option{-bje} for short).
Please report bugs via @url{https://savannah.gnu.org/bugs/?group=nano}.
@node Invoking
@chapter Invoking
The usual way to invoke @command{nano} is:
@iftex
@sp 1
@end iftex
@example
@code{nano [FILE]}
@end example
@iftex
@sp 1
@end iftex
But it is also possible to specify one or more options (see the next
section), and to edit several files in a row. Additionally, the cursor
can be put on a specific line of a file by adding the line number
with a plus sign before the filename, and even in a specific column by
adding it with a comma.
(Negative numbers count from the end of the file or line.)
The cursor can also be put on the first or last occurrence of a specific string
by specifying that string after @code{+/} or @code{+?} before the filename.
The string can be made case sensitive and/or caused to be interpreted as a
regular expression by inserting a @code{c} and/or @code{r} after the plus sign.
These search modes can be explicitly disabled by using the uppercase variant
of those letters: @code{C} and/or @code{R}. When the string contains spaces,
it needs to be enclosed in quotes.
A more complete command synopsis thus is:
@iftex
@sp 1
@end iftex
@example
@code{nano [OPTION]@dots{} [[+LINE[,COLUMN]|+[crCR](/|?)STRING] FILE]@dots{}}
@end example
@iftex
@sp 1
@end iftex
Normally, however, you set your preferred options in a @file{nanorc}
file (@pxref{Nanorc Files}). And when using @code{set positionlog}
(making @command{nano} remember the cursor position when you close a file),
you will rarely need to specify a line number.
As a special case: when instead of a filename a dash is given, @command{nano}
will read data from standard input. This means you can pipe the output of
a command straight into a buffer, and then edit it.
@node Command-line Options
@chapter Command-line Options
@command{nano} takes the following options from the command line:
@table @option
@item -A
@itemx --smarthome
Make the Home key smarter. When Home is pressed anywhere but at the
very beginning of non-whitespace characters on a line, the cursor will
jump to that beginning (either forwards or backwards). If the cursor is
already at that position, it will jump to the true beginning of the
line.
@item -B
@itemx --backup
When saving a file, back up the previous version of it, using the current
filename suffixed with a tilde (@code{~}).
@item -C @var{directory}
@itemx --backupdir=@var{directory}
Make and keep not just one backup file, but make and keep a uniquely
numbered one every time a file is saved --- when backups are enabled.
The uniquely numbered files are stored in the specified directory.
@item -D
@itemx --boldtext
Use bold text instead of reverse video text.
@item -E
@itemx --tabstospaces
Convert typed tabs to spaces.
@item -F
@itemx --multibuffer
Read a file into a new buffer by default.
@item -G
@itemx --locking
Enable vim-style file locking when editing files.
@item -H
@itemx --historylog
Save the last hundred search strings and replacement strings and
executed commands, so they can be easily reused in later sessions.
@item -I
@itemx --ignorercfiles
Don't look at the system's nanorc file nor at the user's nanorc.
@item -J
@itemx --guidestripe
Draw a vertical stripe at the given column, to help judge the width of the
text. (The color of the stripe can be changed with @code{set stripecolor}
in your nanorc file.)
@item -K
@itemx --rawsequences
Interpret escape sequences directly (instead of asking @code{ncurses} to
translate them). If you need this option to get your keyboard to work
properly, please report a bug. Using this option disables @command{nano}'s
mouse support.
@item -L
@itemx --nonewlines
Don't automatically add a newline when a text does not end with one.
(This can cause you to save non-POSIX text files.)
@item -M
@itemx --trimblanks
Snip trailing whitespace from the wrapped line when automatic
hard-wrapping occurs or when text is justified.
@item -N
@itemx --noconvert
Disable automatic conversion of files from DOS/Mac format.
@item -O
@itemx --morespace
Obsolete and ignored option, since the line below the title bar is included
into the editing space by default. If you prefer to keep this line blank,
use @option{-e} or @option{--emptyline}.
@item -P
@itemx --positionlog
For the 200 most recent files, log the last position of the cursor,
and place it at that position again upon reopening such a file.
@item -Q "@var{regex}"
@itemx --quotestr="@var{regex}"
Set the regular expression for matching the quoting part of a line.
The default value is @t{"^([@w{ }\t]*([!#%:;>|@}]|//))+"}.
(Note that @code{\t} stands for a literal Tab character.)
This makes it possible to rejustify blocks of quoted text when composing
email, and to rewrap blocks of line comments when writing source code.
@item -R
@itemx --restricted
Restricted mode: don't read or write to any file not specified on the
command line. This means: don't read or write history files; don't allow
suspending; don't allow spell checking; don't
allow a file to be appended to, prepended to, or saved under a different
name if it already has one; and don't make backup files.
Restricted mode can also be activated by invoking @command{nano} with
any name beginning with @code{r} (e.g.@: @command{rnano}).
@item -S
@itemx --smooth
Obsolete and ignored option, since smooth scrolling has become the default.
If you prefer the chunk-by-chunk scrolling behavior,
use @option{-j} or @option{--jumpyscrolling}.
@item -T @var{number}
@itemx --tabsize=@var{number}
Set the displayed tab length to @var{number} columns. The value of
@var{number} must be greater than 0. The default value is @t{8}.
@item -U
@itemx --quickblank
Do quick status-bar blanking: status-bar messages will disappear after 1
keystroke instead of 25. Note that option @option{-c}
(@option{--constantshow}) overrides this.
@item -V
@itemx --version
Show the current version number and exit.
@item -W
@itemx --wordbounds
Detect word boundaries differently by treating punctuation
characters as parts of words.
@item -X "@var{characters}"
@itemx --wordchars="@var{characters}"
Specify which other characters (besides the normal alphanumeric ones)
should be considered as parts of words. This overrides option
@option{-W} (@option{--wordbounds}).
@item -Y @var{name}
@itemx --syntax=@var{name}
Specify the syntax to be used for highlighting.
@xref{Syntax Highlighting} for more info.
@item -Z
@itemx --zap
Let an unmodified @key{Backspace} or @key{Delete} erase the marked region
(instead of a single character, and without affecting the cutbuffer).
@item -a
@itemx --atblanks
When doing soft line wrapping, wrap lines at whitespace
instead of always at the edge of the screen.
@item -b
@itemx --breaklonglines
Automatically hard-wrap the current line when it becomes overlong.
(This option is the opposite of @option{-w} (@option{--nowrap}) ---
the last one given takes effect.)
@item -c
@itemx --constantshow
Constantly display the cursor position (line number, column number,
and character number) on the status bar.
Note that this overrides option @option{-U} (@option{--quickblank}).
@item -d
@itemx --rebinddelete
Interpret the Delete and Backspace keys differently so that both Backspace
and Delete work properly. You should only use this option when on your
system either Backspace acts like Delete or Delete acts like Backspace.
@item -e
@itemx --emptyline
Do not use the line below the title bar, leaving it entirely blank.
@item -f @var{file}
@itemx --rcfile=@var{file}
Read only this @var{file} for setting nano's options, instead of reading
both the system-wide and the user's nanorc files.
@item -g
@itemx --showcursor
Make the cursor visible in the file browser (putting it on the
highlighted item) and in the help viewer. Useful for braille users
and people with poor vision.
@item -h
@itemx --help
Show a summary of command-line options and exit.
@item -i
@itemx --autoindent
Automatically indent a newly created line to the same number of tabs
and/or spaces as the previous line (or as the next line if the previous
line is the beginning of a paragraph).
@item -j
@itemx --jumpyscrolling
Scroll the buffer contents per half-screen instead of per line.
@item -k
@itemx --cutfromcursor
Make the 'Cut Text' command (normally @kbd{^K}) cut from the current cursor
position to the end of the line, instead of cutting the entire line.
@item -l
@itemx --linenumbers
Display line numbers to the left of the text area.
@item -m
@itemx --mouse
Enable mouse support, if available for your system. When enabled, mouse
clicks can be used to place the cursor, set the mark (with a double
click), and execute shortcuts. The mouse will work in the X Window
System, and on the console when gpm is running. Text can still be
selected through dragging by holding down the Shift key.
@item -n
@itemx --noread
Treat any name given on the command line as a new file. This allows
@command{nano} to write to named pipes: it will start with a blank buffer,
and will write to the pipe when the user saves the "file". This way
@command{nano} can be used as an editor in combination with for instance
@command{gpg} without having to write sensitive data to disk first.
@item -o @var{directory}
@itemx --operatingdir=@var{directory}
Set the operating directory. This makes @command{nano} set up something
similar to a chroot.
@item -p
@itemx --preserve
Preserve the @kbd{^Q} (XON) and @kbd{^S} (XOFF) sequences so data being
sent to the editor can be stopped and started.
@item -r @var{number}
@itemx --fill=@var{number}
Set the target width for justifying and automatic hard-wrapping at this
@var{number} of columns. If the value is 0 or less, wrapping will occur
at the width of the screen minus @var{number} columns, allowing the wrap
point to vary along with the width of the screen if the screen is resized.
The default value is @t{-8}.
@anchor{@option{--speller}}
@item -s "@var{program} [@var{arg} @dots{}]"
@itemx --speller="@var{program} [@var{arg} @dots{}]"
Use the given program to do spell checking and correcting. By default,
@command{nano} uses the command specified in the @env{SPELL} environment
variable. If @env{SPELL} is not set, and @option{--speller} is
not specified either, then @command{nano} uses its own interactive spell
corrector, which requires either @command{hunspell} or GNU @command{spell}
to be installed.
@item -t
@itemx --tempfile
Don't ask whether to save a modified buffer when exiting with @kbd{^X}, but
assume yes. This option is useful when @command{nano} is used as the
composer of a mailer program.
@item -u
@item --unix
Save a file by default in Unix format. This overrides nano's
default behavior of saving a file in the format that it had.
(This option has no effect when you also use @option{--noconvert}.)
@item -v
@itemx --view
Don't allow the contents of the file to be altered: read-only mode.
This mode allows the user to open also other files for viewing,
unless @option{--restricted} is given too.
(Note that this option should NOT be used in place of correct
file permissions to implement a read-only file.)
@item -w
@itemx --nowrap
Do not automatically hard-wrap the current line when it becomes overlong.
This is the default. (This option is the opposite of @option{-b}
(@option{--breaklonglines}) --- the last one given takes effect.)
@anchor{Expert Mode}
@item -x
@itemx --nohelp
Expert Mode: don't show the Shortcut List at the bottom of the screen.
This affects the location of the status bar as well, as in Expert Mode it
is located at the very bottom of the editor.
Note: When accessing the help system, Expert Mode is temporarily
disabled to display the help-system navigation keys.
@item -y
@itemx --afterends
Make Ctrl+Right stop at word ends instead of beginnings.
@item -z
@itemx --suspend
Enable the ability to suspend @command{nano} using the system's suspend
keystroke (usually @kbd{^Z}).
@item -$
@itemx --softwrap
Enable 'soft wrapping'. This will make @command{nano} attempt to display the
entire contents of any line, even if it is longer than the screen width, by
continuing it over multiple screen lines. Since
@code{$} normally refers to a variable in the Unix shell, you should specify
this option last when using other options (e.g.@: @code{nano -wS$}) or pass it
separately (e.g.@: @code{nano -wS -$}).
@end table
@node Editor Basics
@chapter Editor Basics
@menu
* Entering Text::
* Commands::
* The Cutbuffer::
* The Mark::
* Screen Layout::
* Search and Replace::
* Using the Mouse::
* Limitations::
@end menu
@node Entering Text
@section Entering Text
@command{nano} is a "modeless" editor. This means that all keystrokes,
with the exception of Control and Meta sequences, enter text into the
file being edited.
Characters not present on the keyboard can be entered in two ways:
@itemize @bullet
@item
For characters with a single-byte code,
pressing the Esc key twice and then typing a three-digit decimal number
(from @kbd{000} to @kbd{255}) will make @command{nano} behave as if you
typed the key with that value.
@item
For any possible character, pressing @kbd{M-V} (Alt+V) and then typing a
six-digit hexadecimal number (starting with @kbd{0} or @kbd{1}) will enter the
corresponding Unicode character into the buffer.
@end itemize
For example, typing @kbd{Esc Esc 2 3 4} will enter the character "ê" ---
useful when writing about a French party. Typing @kbd{M-V 0 0 2 2 c 4}
will enter the symbol "⋄", a little diamond.
@node Commands
@section Commands
Commands are given by using the Control key (Ctrl, shown as @kbd{^})
or the Meta key (Alt or Cmd, shown as @kbd{M-}).
@itemize @bullet
@item
A control-key sequence is entered by holding down the Ctrl key and
pressing the desired key.
@item
A meta-key sequence is entered by holding down the Meta key (normally
the Alt key) and pressing the desired key.
@end itemize
If for some reason on your system the combinations with Ctrl or Alt do
not work, you can generate them by using the Esc key. A control-key
sequence is generated by pressing the Esc key twice and then pressing
the desired key, and a meta-key sequence by pressing the Esc key once
and then pressing the desired key.
@node The Cutbuffer
@section The Cutbuffer
Text can be cut from a file, a whole line at a time, by using the 'Cut Text'
command (default key binding: @kbd{^K}). The cut line is stored in
the cutbuffer. Consecutive strokes of @kbd{^K} will add each cut line
to this buffer, but a @kbd{^K}
after any other keystroke will overwrite the entire cutbuffer.
The contents of the cutbuffer can be pasted back into the file with the
'Uncut Text' command (default key binding: @kbd{^U}).
A line of text can be copied into the cutbuffer (without cutting it) with
the 'Copy Text' command (default key binding: @kbd{M-6}).
@node The Mark
@section The Mark
Text can be selected by first 'setting the Mark' (default key bindings:
@kbd{^6} and @kbd{M-A}) and then moving the cursor to the other end of the portion
to be selected. The selected portion of text will be highlighted.
This selection can now be cut or copied in its entirety with a single
@kbd{^K} or @kbd{M-6}. Or the selection can be used to limit the scope of
a search-and-replace (@kbd{^\}) or spell-checking session (@kbd{^T}).
On some terminals, text can be selected also by holding down @kbd{Shift}
while using the cursor keys. Holding down the @kbd{Ctrl} or @kbd{Alt}
key too will increase the stride. Such a selection is cancelled
upon any cursor movement where @kbd{Shift} isn't held.
Cutting or copying selected text will toggle the mark off automatically.
If necessary, it can be toggled off manually with another @kbd{^6} or @kbd{M-A}.
@node Screen Layout
@section Screen Layout
The default screen of nano consists of five areas. From top to bottom
these are: the title bar, a blank line, the edit window, the status bar,
and two help lines.
The title bar consists of
three sections: left, center and right. The section on the left
displays the version of @command{nano} being used. The center section
displays the current filename, or "New Buffer" if the file has not yet
been named. The section on the right displays "Modified" if the
file has been modified since it was last saved or opened.
The status bar is the third line from the bottom of the screen. It
shows important and informational messages. Any error messages that
occur from using the editor will appear on the status bar. Any questions
that are asked of the user will be asked on the status bar, and any user
input (search strings, filenames, etc.) will be input on the status bar.
The two help lines at the bottom of the screen show some of the most
essential functions of the editor. These two lines are called the
Shortcut List.
@node Search and Replace
@section Search and Replace
One can search the current buffer for the occurrence of any string
with the Search command (default key binding: @kbd{^W}). The default search
mode is forward, case-insensitive, and for literal strings. But one
can search backwards by pressing @kbd{M-B}, search case sensitively with @kbd{M-C},
and interpret regular expressions in the search string with @kbd{M-R}.
A regular expression in a search string always covers just one line;
it cannot span multiple lines. And when replacing (with @kbd{^\} or @kbd{M-R})
the replacement string cannot contain a newline (LF).
@node Using the Mouse
@section Using the Mouse
When mouse support has been configured and enabled, a single mouse click
places the cursor at the indicated position. Clicking a second time in
the same position toggles the mark. Clicking in the shortcut list
executes the selected shortcut. To be able to select text with the
left button, or paste text with the middle button, hold down the
Shift key during those actions.
The mouse will work in the X Window System, and on the console when gpm
is running.
@node Limitations
@section Limitations
The recording and playback of keyboard macros works correctly only on a
terminal emulator, not on a Linux console (VT), because the latter does
not by default distinguish modified from unmodified arrow keys.
@node Built-in Help
@chapter Built-in Help
The built-in help system in @command{nano} is available by pressing @kbd{^G}.
It is fairly self-explanatory. It documents the various parts of the
editor and the available keystrokes. Navigation is via the @kbd{^Y} (Page Up)
and @kbd{^V} (Page Down) keys. @kbd{^X} exits from the help system.
@node Feature Toggles
@chapter Feature Toggles
</