[http://www.nano-editor.org/ 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 is the default console editor in distributions such as Ubuntu and supports features including colorized syntax highlighting, DOS/Mac file type conversions, spellchecking and [[Wikipedia:UTF-8|UTF-8]] encoding. nano opened with an empty buffer typically occupies under 1.5 MB of resident memory. [http://i275.photobucket.com/albums/jj281/adamchrista/Arch%20Linux/Wiki%20Examples/nano-man.png nano Screenshot].

[http://www.nano-editor.org/ 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 is the default console editor in distributions such as Ubuntu and supports features including colorized syntax highlighting, DOS/Mac file type conversions, spellchecking and [[Wikipedia:UTF-8|UTF-8]] encoding. nano opened with an empty buffer typically occupies under 1.5 MB of resident memory. [http://i275.photobucket.com/albums/jj281/adamchrista/Arch%20Linux/Wiki%20Examples/nano-man.png nano Screenshot].

−

== Package Installation ==

+

== Package installation ==

−

{{Pkg|nano}} is part of the [[Official Repositories|Arch Linux [core] repository]], usually installed by default by AIF.

+

You can install the {{Pkg|nano}} package from the [[official repositories]]. It is likely that is already on your system, as it is included in the {{grp|base}} group.

== Configuration ==

== Configuration ==

=== Creating ~/.nanorc ===

=== Creating ~/.nanorc ===

The look, feel and function of nano is typically controlled by way of either command-line arguments, or configuration commands within the file {{Ic|~/.nanorc}}.<br>

The look, feel and function of nano is typically controlled by way of either command-line arguments, or configuration commands within the file {{Ic|~/.nanorc}}.<br>

−

A sample configuration file is installed upon program installation and is located at {{Ic|/etc/nanorc}}.The file {{Ic|~/.nanorc}} must be first created by the user:

+

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

Then include the file in your {{ic|~/.nanorc}} or to {{ic|/etc/nanorc}} by adding the following line:

+

include "/etc/nano/pkgbuild.nanorc"

−

or to {{Ic|/etc/nanorc}}.

+

==== Other definitions ====

+

Syntax highlighting enhancements which replace and expand the defaults can be found in the AUR, {{AUR|nano-syntax-highlighting-git}}.

−

=== Suggested Configuration ===

+

=== Suggested configuration ===

==== Suspension ====

==== Suspension ====

−

Unlike most interactive programs, suspension is not enabled by default. To change this, uncomment the 'set suspend' line in {{Ic|/etc/nanorc}}. This will allow you to use the keys {{Keypress|Ctrl+z}} to send nano to the background.

+

Unlike most interactive programs, suspension is not enabled by default. To change this, uncomment the 'set suspend' line in {{Ic|/etc/nanorc}}. This will allow you to use the keys {{ic|Ctrl+z}} to send nano to the background.

==== Do not wrap text ====

==== Do not wrap text ====

Line 87:

Line 88:

set nowrap

set nowrap

−

== nano Usage ==

+

== nano usage ==

−

=== Special Functions ===

+

=== Special functions ===

−

* {{Keypress|Ctrl}} key modified shortcuts ({{Ic|^}}) representing commonly used functions are listed along the bottom two lines of the nano screen.

+

* {{ic|Ctrl}} key modified shortcuts ({{Ic|^}}) representing commonly used functions are listed along the bottom two lines of the nano screen.

{{Note|This method can be considered draconian and may not be suitable for all users. Nonetheless, the following procedure exists as a viable example solution.}}

{{Note|This method can be considered draconian and may not be suitable for all users. Nonetheless, the following procedure exists as a viable example solution.}}

−

===== Symbolic Linking =====

+

===== Symbolic linking =====

As root, or with {{Ic|su -}}

As root, or with {{Ic|su -}}

Line 185:

Line 187:

# ln -s /usr/bin/nano /usr/bin/vi

# ln -s /usr/bin/nano /usr/bin/vi

−

Assuming sudo is installed and properly configured

+

Assuming sudo is installed and properly configured. You will need to add {{Ic|vi}} to the {{ic|IgnorePkg}} list in {{ic|pacman.conf}} to make this permanent. Otherwise it will revert back to {{Ic|vi}} the next time it is updated.

===== Restoration of vi =====

===== Restoration of vi =====

Line 194:

Line 196:

mv /usr/bin/vi.old /usr/bin/vi

mv /usr/bin/vi.old /usr/bin/vi

−

==== Method Four ====

+

==== Method four ====

{{Note|This method can be considered draconian and may not be suitable for all users. Nonetheless, the following procedure exists as a viable example solution.}}

{{Note|This method can be considered draconian and may not be suitable for all users. Nonetheless, the following procedure exists as a viable example solution.}}

−

===== Removal & Symbolic Linking =====

+

===== Removal & symbolic linking =====

Use [[Pacman|pacman]] to remove the {{Ic|vi}} package, its configuration, and all unneeded dependencies:

Use [[Pacman|pacman]] to remove the {{Ic|vi}} package, its configuration, and all unneeded dependencies:

pacman -Rns vi

pacman -Rns vi

Line 211:

Line 213:

pacman -S vi

pacman -S vi

−

{{Box Note|Do not clean {{Ic|-c}} or refresh {{Ic|-y}} the package database if you wish to retain the previously installed version of the {{Ic|vi}} package.<br>If this case, subsequent updates will also require the judicious use of the {{Ic|--ignore vi}} switch (and optionally {{Ic|--ignore glibc ncurses coreutils}}).|}}

+

{{Note|Do not clean {{Ic|-c}} or refresh {{Ic|-y}} the package database if you wish to retain the previously installed version of the {{Ic|vi}} package.<br>If this case, subsequent updates will also require the judicious use of the {{Ic|--ignore vi}} switch (and optionally {{Ic|--ignore glibc ncurses coreutils}}).|}}

Revision as of 12:19, 25 February 2014

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 is the default console editor in distributions such as Ubuntu and 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 1.5 MB of resident memory. nano Screenshot.

Package installation

You can install the nano package from the official repositories. It is likely that is already on your system, as it is included in the base group.

Configuration

Creating ~/.nanorc

The look, feel and function of nano is typically controlled by way of either command-line arguments, or configuration commands within the file ~/.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 ~/.nanorc:

Other definitions

Suggested configuration

Suspension

Unlike most interactive programs, suspension is not enabled by default. To change this, uncomment the 'set suspend' line in /etc/nanorc. This will allow you to use the keys Ctrl+z to send nano to the background.

Do not wrap text

If you are coming from another distribution, you might wonder about nano's strange behaviour, so just edit /etc/nanorc like this:

## Do not wrap text at all.
set nowrap

nano usage

Special functions

Ctrl key modified shortcuts (^) representing commonly used functions are listed along the bottom two lines of the nano screen.

Tips & tricks

Replacing vi with nano

Casual users may prefer the use of nano over vi for its simplicity and ease of use and may opt to replace vi with nano as the default text editor for commands such as visudo.

Method one

Warning: From man 8 visudo: Note that this can be a security hole since it allows the user to execute any program they wish simply by setting VISUAL or EDITOR.

sudo from the core repository is compiled with --with-env-editor by default and honors the use of the VISUAL and EDITOR variables. To establish nano as the visudo editor for the duration of the current shell session, set and export the EDITOR variable before calling visudo.

export EDITOR=nano

Example usage

export EDITOR=nano && sudo visudo

Method two

Warning: From man 8 visudo: Note that this can be a security hole since it allows the user to execute any program they wish simply by setting VISUAL or EDITOR.

The EDITOR variable can also be set within the following files for persistent use:

Example .bash_profile

Method three

Note: This method can be considered draconian and may not be suitable for all users. Nonetheless, the following procedure exists as a viable example solution.

Symbolic linking

As root, or with su -

Rename the vi executable to vi.old for ease of restoration:

# mv /usr/bin/vi /usr/bin/vi.old

Create a symbolic link from /usr/bin/nano to /usr/bin/vi

# ln -s /usr/bin/nano /usr/bin/vi

Assuming sudo is installed and properly configured. You will need to add vi to the IgnorePkg list in pacman.conf to make this permanent. Otherwise it will revert back to vi the next time it is updated.

Restoration of vi

Remove the /usr/bin/vi symbolic link:

unlink /usr/bin/vi

Rename the vi.old executable back to vi:

mv /usr/bin/vi.old /usr/bin/vi

Method four

Note: This method can be considered draconian and may not be suitable for all users. Nonetheless, the following procedure exists as a viable example solution.

Removal & symbolic linking

Use pacman to remove the vi package, its configuration, and all unneeded dependencies:

pacman -Rns vi

Create a symbolic link from /usr/bin/nano to /usr/bin/vi:

ln -s /usr/bin/nano /usr/bin/vi

Restoration of vi

Remove the /usr/bin/vi symbolic link:

unlink /usr/bin/vi

Use pacman to install the previously deinstallled vi package:

pacman -S vi

Note: Do not clean -c or refresh -y the package database if you wish to retain the previously installed version of the vi package.If this case, subsequent updates will also require the judicious use of the --ignore vi switch (and optionally --ignore glibc ncurses coreutils).