Ubuntu/Debian/Mint news and tutorials | Linux gaming
facebook.png
twitter.png
feed.png
Quick Tip
Disable Overlay Scrollbars in GNOME
gsettings set com.canonical.desktop.interface scrollbar-mode normal
Quick Tip
Find Files Containing a Text Pattern
find . -iname "*.txt" -exec grep -l "hello" {} +
Categories
Online Readers
Advertise on TuxArena
Linux Cheat Sheet

Have a look at our Linux Cheat Sheet for quick one-liners, commands and tips.

The popular, user-friendly, terminal-based text editor Nano has reached version 2.4 today, and comes with several new features, including ‘undo’ functionality.

nano01


Although the de-facto editor which comes installed by default on virtually any Linux distribution is Vim, Nano is also widely used, having some good features like syntax highlighting or indentation. But Nano’s true strength comes from its ease of use, being user-friendly to beginners, fast and useful in various situations, especially when dealing with quick edits of configuration or just plain text files.

nano02

Undo Support

The main feature in Nano 2.4 is the introduction of support for the ‘undo/redo’ functions, which can be used by pressing Alt+U to undo and Alt+E to redo the last action. The undo support was experimental in 2.2, and now has been introduced as fully supported.

nano03

There is also a big number of fixes that went into this release, see the changelog for the full list.

Config

Despite having a simple interface, Nano can also be used for programming, having features like syntax highlighting, indentation, searching, and powerful configuration options which can be put inside the $HOME/.nanorc file, like changing its behavior, enable or disable text wrapping or backup files.

Here’s an example:

include "/usr/share/nano/c.nanorc" # c syntax highlighting
include "/usr/share/nano/perl.nanorc" # perl syntax highlighting
include "/usr/share/nano/sh.nanorc" # sh syntax highlighting
set autoindent # enable autoindent
unset backup # disable backup files ending in ~
set nonewlines
set tabsize 2 # set tab size to two spaces
set nowrap # disable word wrapping

Some basic keyboard shortcuts to use with Nano are: Ctrl+X to quit, Ctrl+O to save a file, Ctrl+W to search and Ctrl+K to cut text.

You can even enable/disable mouse support using Alt+M. Once the mouse support is on, you can use your mouse to move the text cursor to another position. Although keyboard shortcuts are faster I believe (like Ctrl+N/Ctrl+P to go to next/previous line, Ctrl+F/Ctrl+B to go to the next/previous character), the mouse may still come in handy for some users.

Install Nano 2.4 in Ubuntu 14.04/14.10 and Mint 17/17.1

To compile Nano from source, get the tarball from here (direct link here), then uncompress it (tar -xf nano-2.4.0.tar.gz).

Install the development libraries:

sudo apt-get build-dep nano

Change the current directory to nano-2.4.0 and type:

./configure
make
sudo make install

Alternatively, you can install it as normal user by specifying a prefix:

./configure --prefix=$HOME/usr
make
make install

In this case Nano will be installed as $HOME/usr/bin/nano, so make sure to add $HOME/usr/bin to your PATH variable.

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.