[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 [http://www.ubuntu.com/ Ubuntu] and supports features including colorized syntax highlighting, DOS/Mac file type conversions, spellchecking and [http://en.wikipedia.org/wiki/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|official Arch Linux [core] repository]].

+

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

−

+

−

$ pacman -Si nano

+

−

<pre>Repository : core

+

−

Name : nano

+

−

Version : 2.2.5-1

+

−

URL : http://www.nano-editor.org

+

−

Licenses : GPL

+

−

Groups : base

+

−

Provides : None

+

−

Depends On : glibc ncurses

+

−

Optional Deps : None

+

−

Conflicts With : None

+

−

Replaces : None

+

−

Download Size : 295.66 K

+

−

Installed Size : 1508.00 K

+

−

Packager : Andreas Radke <andyrtr@archlinux.org>

+

−

Architecture : x86_64

+

−

Build Date : Mon 09 Aug 2010 10:52:08 AM PDT

+

−

MD5 Sum : 320ff5bf6e073d8f6a7c26ab67e3aef6

+

−

Description : Pico editor clone with enhancements</pre>

+

−

+

−

Install the latest version of nano:

+

−

# pacman -S nano

+

== Configuration ==

== Configuration ==

Line 44:

Line 23:

{{Note|Command-line arguments override and take precedence over the configuration commands established in .nanorc|}}

{{Note|Command-line arguments override and take precedence over the configuration commands established in .nanorc|}}

−

====Nano syntax highlight for PKGBUILD====

+

=== Syntax highlighting ===

−

+

==== for PKGBUILD files ====

−

This new version highlights like the ArchLinux [http://projects.archlinux.org/svntogit/packages.git/tree "svntogit-server"].

+

This new version highlights like the Arch Linux [https://projects.archlinux.org/svntogit/packages.git/tree "svntogit-server"].

# Arch PKGBUILD files

# Arch PKGBUILD files

#

#

Line 68:

Line 47:

color brightblack "#.*$"

color brightblack "#.*$"

−

This is another version from this [http://bbs.archlinux.org/viewtopic.php?pid=565476 forumthread].

+

This is another version from this [https://bbs.archlinux.org/viewtopic.php?pid=565476 forum thread].

## Arch PKGBUILD files

## Arch PKGBUILD files

Line 96:

Line 75:

To use, save as /usr/share/nano/pkgbuild.nanorc and add:

To use, save as /usr/share/nano/pkgbuild.nanorc and add:

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

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

−

to your ~/.nanorc

+

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

−

or to /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 '/etc/nanorc'. This will allow you to use the keys 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 {{Keypress|Ctrl+z}} to send nano to the background.

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

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

Line 110:

Line 90:

set nowrap

set nowrap

−

== nano Usage ==

+

== nano usage ==

−

=== Special Functions ===

+

=== Special functions ===

−

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

+

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

: Toggles the display of the shortcut list at the bottom of the nano screen for additional screen space

: Toggles the display of the shortcut list at the bottom of the nano screen for additional screen space

{{Tip|[http://www.nano-editor.org/dist/v2.1/nano.html#Feature-Toggles Feature Toggles] lists the global toggles available for nano.|}}

{{Tip|[http://www.nano-editor.org/dist/v2.1/nano.html#Feature-Toggles Feature Toggles] lists the global toggles available for nano.|}}

−

== Tips & Tricks ==

+

== Tips & tricks ==

+

=== Replacing vi with nano ===

+

Casual users may prefer the use of {{Ic|nano}} over {{Ic|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'''.

−

=== Replacing {{Ic|vi}} with {{Ic|nano}} ===

+

==== Method one ====

−

+

−

Casual users may prefer the use of {{Ic|nano}} over {{Ic|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 <code>visudo</code>.

+

−

+

−

==== Method One ====

+

{{Warning|From {{Ic|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.''}}

{{Warning|From {{Ic|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|sudo]] from the core repository is compiled with <code>--with-env-editor</code> by default and honors the use of the {{Ic|VISUAL}} and {{Ic|EDITOR}} variables. To establish nano as the <code>visudo</code> editor for the duration of the current shell session, set and export the {{Ic|EDITOR}} variable before calling <code>visudo</code>

+

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

export EDITOR=nano

export EDITOR=nano

−

===== Example Usage =====

+

===== Example usage =====

−

+

export EDITOR=nano && sudo visudo

export EDITOR=nano && sudo visudo

−

==== Method Two ====

+

==== Method two ====

{{Warning|From {{Ic|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.''}}

{{Warning|From {{Ic|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.''}}

Line 188:

Line 165:

===== Example .bash_profile =====

===== Example .bash_profile =====

−

+

{{Bc|. $HOME/.bashrc|

−

<pre>. $HOME/.bashrc

+

export EDITOR=nano

export EDITOR=nano

Line 197:

Line 173:

startx

startx

logout

logout

−

fi</pre>

+

fi

+

}}

−

==== Method Three ====

+

==== 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.}}

{{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 <code>su -</code>

+

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

−

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

+

Rename the {{Ic|vi}} executable to {{Ic|vi.old}} for ease of restoration:

−

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

+

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

−

Assuming sudo is installed and properly configured

+

Create a symbolic link from {{Ic|/usr/bin/nano}} to {{Ic|/usr/bin/vi}}

+

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

−

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

+

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.

−

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

+

−

===== Overview of Commands =====

+

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

−

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

+

Remove the {{Ic|/usr/bin/vi}} symbolic link:

−

* Rename the {{Ic|vi}} executable to {{Ic|vi.old}} for ease of restoration

+

unlink /usr/bin/vi

−

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

+

−

* Create a symbolic link from {{Ic|/usr/bin/nano}} to {{Ic|/usr/bin/vi}}

+

−

===== Restoration of {{Ic|vi}} =====

+

Rename the {{Ic|vi.old}} executable back to {{Ic|vi}}:

−

unlink /usr/bin/vi

+

−

* Remove the {{Ic|/usr/bin/vi}} symbolic link

+

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

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

−

* Rename the {{Ic|vi.old}} executable back to {{Ic|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:

pacman -Rns vi

pacman -Rns vi

−

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

−

===== Overview of Commands =====

+

Create a symbolic link from {{Ic|/usr/bin/nano}} to {{Ic|/usr/bin/vi}}:

−

pacman -Rns vi

+

−

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

+

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

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

−

* Create a symbolic link from {{Ic|/usr/bin/nano}} to {{Ic|/usr/bin/vi}}

−

===== Restoration of {{Ic|vi}} =====

+

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

+

Remove the {{Ic|/usr/bin/vi}} symbolic link:

unlink /usr/bin/vi

unlink /usr/bin/vi

−

* Remove the {{Ic|/usr/bin/vi}} symbolic link

+

−

pacman -S vi

+

Use pacman to install the previously deinstallled {{Ic|vi}} package:

−

* Use pacman to install the previously deinstallled {{Ic|vi}} package

+

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}}).|}}

{{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}}).|}}

Revision as of 04:41, 16 March 2013

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

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.The file ~/.nanorc must be first created by the user:

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 Template:Keypress 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

Template:Keypress 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: