Nano
GNU's nano is [[Article description::an easy to use text editor with additional functionality.]] nano is Gentoo's default editor and is part of each installation. It can be replaced without problems by any other text editor.
Installation
USE flags
USE flags for app-editors/nano GNU GPL'd Pico clone with more functionality
debug
|
Enable debug messages and assert warnings. Note that these will all be sent straight to stderr rather than some logging facility. |
justify
|
Enable justify/unjustify functions for text formatting. |
magic
|
Add magic file support (sys-apps/file) to automatically detect appropriate syntax highlighting |
minimal
|
Disable all fancy features, including ones that otherwise have a dedicated USE flag (such as spelling). |
ncurses
|
Add ncurses support (console display library) |
nls
|
Add Native Language Support (using gettextGNU locale utilities) |
spell
|
Add dictionary support |
split-usr
|
Enable this if /bin and /usr/bin are separate directories |
static
|
!!do not set this during bootstrap!! Causes binaries to be statically linked instead of dynamically |
unicode
|
Add support for Unicode |
Emerge
root #
emerge --ask app-editors/nano
Usage
First steps
Start nano by typing nano in a terminal followed by options or a file. Passing a file name is the most common use:
user $
nano filename
Nano now shows the content of the text file and which can be modified as desired. Navigate through the text with the arrow keys.
At the bottom nano shows shortcuts for common actions, e.g. save or exit. The shortcut to save is shown as ^O
. Prefix the shortcut with the Ctrl key. So to save a document (after editing it) press Ctrl+O. To exit press Ctrl+X.
To edit configuration files always pass nano the
-w
option. Without the -w
option long lines become wrapped lines. This creates problems when saving because the lines are saved as wrapped lines instead of how they were in the original file. Many time this will break configuration files.To see an overview over all options run nano --help
Cut, copy, and paste
Lines can be cut with the shortcut Ctrl+K (copied with Alt+^) and paste with Ctrl+U. To cut or copy multiple lines press the shortcut multiple times.
Search
Search the text with Ctrl+W. Continue the search with Alt+W.
More shortcuts
Action | Shortcut | Other shortcut |
---|---|---|
Show the help | Ctrl+G | F1 |
Close file | Ctrl+X | F2 |
Save file | Ctrl+O | F3 |
Search text | Ctrl+W | F6 |
Continue search | Alt+W | F16 |
Copy line to clipboard | Alt+^ | Alt+6 |
Cut line to clipboard | Ctrl+K | F9 |
Paste line from clipboard | Ctrl+U | F10 |
Configuration
Set options permanently in the /etc/nanorc configuration file. This configuration applies system wide to all users. To change options only for one user, set the option in the user's ~/.nanorc file. As a general rule, files present in a user's home directory override system wide settings.
See also
- Nano/Basics Guide — covers basic operations in nano, and is meant to be very concise.
- Vim — a text editor based on the vi text editor.