nano

GNU nano (or nano) is a text editor which aims to introduce a simple interface and intuitive command options to console based text editing. nano supports features including colorized syntax highlighting, DOS/Mac file type conversions, spellchecking and UTF-8 encoding. nano opened with an empty buffer typically occupies under 4 MB of resident memory.

Installation

Install the nano package.

Configuration

The look, feel, and function of nano is typically controlled by way of either command-line arguments, or configuration commands within the file ~/.config/nano/nanorc.

A sample configuration file is installed upon program installation and is located at /etc/nanorc. To customize your nano configuration, first create a local copy at ~/.config/nano/nanorc:

$ cp /etc/nanorc ~/.config/nano/nanorc

Proceed to establish the nano console environment by setting and/or unsetting commands within ~/.config/nano/nanorc file.

Tip: nanorc(5) details the complete list configuration commands available for nano.
Note: Command-line arguments override and take precedence over the configuration commands established in ~/.config/nano/nanorc

Syntax highlighting

Nano ships with predefined syntax highlighting rules, defined in /usr/share/nano/*.nanorc. To enable them, add the following line to your ~/.config/nano/nanorc or to /etc/nanorc:

include "/usr/share/nano/*.nanorc"

For syntax highlighting enhancements which replace and expand the defaults, install nano-syntax-highlighting or nano-syntax-highlighting-gitAUR and, additionally to the above setting, also add:

include "/usr/share/nano-syntax-highlighting/*.nanorc"

Forth

See https://paste.xinu.at/wc17YG/ for Forth highlighting.

PKGBUILD

Save https://paste.xinu.at/4ss/ (similar to Arch's old svntogit server) to and include it:

include "/etc/nano/pkgbuild.nanorc"

Suspension

Unlike most interactive programs, suspension is not enabled by default. To change this, uncomment the set suspendable line in . This will allow you to use the keys to send nano to the background.

Usage

Shortcuts can be viewed from inside nano. See the nano online help files via Ctrl+g within nano and the nano Command Manual for complete descriptions and additional support.

See also the cheatsheet for nano.

Special functions

Keyboard shortcuts representing commonly used functions are listed along the bottom two lines of the nano screen.

They can be toggled by:

  • for based shortcuts
  • (typically ) or for based shortcuts

Tips and tricks

Replacing vi with nano

To replace vi with nano as the default text editor for commands such as visudo, set the and environment variables, for example:

export VISUAL=nano
export EDITOR=nano

Troubleshooting

Hijacked keybindings

Some window managers have keybindings that conflict with nano, for example Alt+Enter. Remove or remap them to e.g Super (with for , and ) and restart the window manager.

See also

This article is issued from Archlinux. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.