<p>Text editors are highly subjective and highly opinionated commodities. Everyone is aware of infamous rivalry between users of Emacs and Vi/Vim. Every single text editor has its own strengths and weaknesses. At the end of the day it's the question of your personal preferences and muscle memory when it comes to default key-bindings. Both Emacs and Vim have a learning curve. Steepness of that curve depends on the person's background and interests. Hey, but today I'm not here to talk about Emacs and Vim. I'm here to talk about a simple, easy to use and almost ever present text editor called <code>GNU nano</code>. So what exactly is this <code>nano</code> text editor? Well, according to documentation available on <code>GNU nano</code>'s <a href="https://nano-editor.org/">website</a>,</p>
<blockquote>
<p>GNU nano was designed to be a free replacement for the Pico text editor, part of the Pine email suite from The University of Washington. It aimed to "emulate Pico as closely as is reasonable and then include extra functionality".</p>
</blockquote>
<p>Pico and Pine email suites are still around so what was the need to create <code>nano</code> in the first place? The answer is license. Pico and Pine email suites nowadays are available under Apache-2.0 license but that always wasn't the case and this ambiguity in the original licensing terms of the Pico editor led to the creation of <code>nano</code>. It was first created in 1999 with the name TIP (an acronym for TIP Isn't Pico), by Chris Allegretta. The name was changed to <code>nano</code> on January 10th, 2000 to avoid a naming conflict with the existing Unix utility tip. The name comes from the system of SI prefixes, in which <code>nano</code> is 1000 times larger than pico. In February 2001, <code>nano</code> became a part of the GNU Project. BTW if you want to know more about SI prefixes, I'd highly recommend you to listen to <a href="https://hackerpublicradio.org/eps.php?id=3454">HPR episode 3453 - Engineering notation</a> by Ken Fallon.</p>
<p><code>nano</code> is really small in footprint and is relatively easy to use compared to Emacs and Vim and perhaps this is the reason why you'd invariably find it already installed on almost all GNU/Linux distributions. If you have ever used <code>nano</code> before you might have noticed that it looks kinda boring; there are no line-numbers nor there is any syntax highlighting and spell-checking also seems absent. But this is not true. <code>nano</code> has all of these features and even some more like regex searches, indentation, multiple buffers, available at its disposal. Then why does it come across as a plain Jane? The short answer is, I honestly don't know! For some unknown and obscure reasons many of <code>nano</code>'s cool features are disabled by default. This results in <code>nano</code> coming across as a plain Jane little text editor that is uncool. And as I mentioned earlier, that is not true. But worry not! It is so darn easy to unleash the true potential of <code>nano</code> and make it shine. Are you ready? Great! Let's do it together then!</p>
<p>First thing we need to to do is create a file with the name <code>.nanorc</code> in the <code>$HOME</code> directory. Open your terminal emulator and run,</p>
<pre class="text"><code>touch $HOME/.nanorc
</code></pre>
<p>We'd also need to create a directory called <code>Nano_Backups</code> in our <code>Documents</code> directory. To do so run the following command,</p>
<pre class="text"><code>mkdir -p $HOME/Documents/Nano_Backups
</code></pre>
<p>Next open that <code>.nanorc</code> file and simply paste the following content in it,</p>
<pre class="text"><code>set atblanks
set autoindent
set backup
set backupdir &quot;/home/USERNAME/Documents/Nano_Backups&quot;
set boldtext
set constantshow
set cutfromcursor
set indicator
set linenumbers
set magic
set minibar
set mouse
set showcursor
set softwrap
set speller &quot;aspell -x -c&quot;
set trimblanks
set whitespace &quot;&#187;&middot;&quot;
set zap
set multibuffer

set titlecolor bold,lightwhite,blue
set promptcolor lightwhite,lightblack
set statuscolor bold,lightwhite,green
set errorcolor bold,lightwhite,red
set spotlightcolor black,lime
set selectedcolor lightwhite,magenta
set stripecolor ,yellow
set scrollercolor cyan
set numbercolor cyan
set keycolor cyan
set functioncolor green

include &quot;/usr/share/nano/*.nanorc&quot;

bind ^Q exit all
bind ^S savefile main
bind ^W writeout main
bind ^O insert main
bind ^H help all
bind ^H exit help
bind ^F whereis all
bind ^G findnext all
bind ^B wherewas all
bind ^D findprevious all
bind ^R replace main
bind ^X cut main
bind ^C copy main
bind ^V paste all
bind ^P location main
bind ^E execute main
bind ^A mark main
unbind ^K main
unbind ^U all
unbind ^N main
unbind ^Y all
unbind M-J main
unbind M-T main
bind ^T gotoline main
bind ^T gotodir browser
bind ^T cutrestoffile execute
bind ^L linter execute
bind M-U undo main
bind M-R redo main
bind ^Z undo main
bind ^Y redo main
</code></pre>
<p>You'll have to replace <code>USERNAME</code> in the line number four, <code>set backupdir "/home/USERNAME/Documents/Nano_Backups/"</code> with your actual <code>username</code> and then save this file.</p>
<p>Wouldn't it be nice if the colors in <code>nano</code> were different for a normal user and a root user? Yes, for sure. To do so create an empty <code>.nanorc</code> file in the root's directory,</p>
<pre class="text"><code>sudo touch /root/.nanorc
</code></pre>
<p>Next create the backup directory <code>Nano_Backups</code> in root's <code>Documents</code> directory. To do so run the following command,</p>
<pre class="text"><code>sudo mkdir -p /root/Documents/Nano_Backups
</code></pre>
<p>Open that <code>/root/.nanorc</code>file and paste this content in it and save the changes,</p>
<pre class="text"><code>set atblanks
set autoindent
set backup
set backupdir &quot;/root/Documents/Nano_Backups/&quot;
set boldtext
set constantshow
set cutfromcursor
set indicator
set linenumbers
set magic
set minibar
set mouse
set showcursor
set softwrap
set speller &quot;aspell -x -c&quot;
set trimblanks
set whitespace &quot;&#187;&middot;&quot;
set zap
set multibuffer

set titlecolor bold,lightwhite,magenta
set promptcolor black,yellow
set statuscolor bold,lightwhite,magenta
set errorcolor bold,lightwhite,red
set spotlightcolor black,orange
set selectedcolor lightwhite,cyan
set stripecolor ,yellow
set scrollercolor magenta
set numbercolor magenta
set keycolor lightmagenta
set functioncolor magenta

include &quot;/usr/share/nano/*.nanorc&quot;

bind ^Q exit all
bind ^S savefile main
bind ^W writeout main
bind ^O insert main
bind ^H help all
bind ^H exit help
bind ^F whereis all
bind ^G findnext all
bind ^B wherewas all
bind ^D findprevious all
bind ^R replace main
bind ^X cut main
bind ^C copy main
bind ^V paste all
bind ^P location main
bind ^E execute main
bind ^A mark main
unbind ^K main
unbind ^U all
unbind ^N main
unbind ^Y all
unbind M-J main
unbind M-T main
bind ^T gotoline main
bind ^T gotodir browser
bind ^T cutrestoffile execute
bind ^L linter execute
bind M-U undo main
bind M-R redo main
bind ^Z undo main
bind ^Y redo main
</code></pre>
<p>What we have just done is, we have enabled some useful features of <code>nano</code> and changed the default keybindings to the more familiar ones like <code>Ctrl+C</code> for copying, <code>Ctrl+X</code> for cutting, <code>Ctrl+V</code> for pasting and a bunch of other key combinations. We've also enabled automatic backing-up of documents. Backups will get saved in the user's <code>Documents/Nano_Backups</code> directory.</p>
<p>Spell checker is enabled in <code>nano</code> via this configuration but to utilize it you'll have to install <code>aspell</code> and <code>aspell-dictionary</code> from your package manager.</p>
<p>Kudos! We have turned a timid <code>GNU nano</code> into a powerful wildebeest. Try this configuration and if possible leave your feedback.</p>
<p>A word of warning. Package maintainers often ship stripped down versions of <code>nano</code> so one of these features might not be present in your installation and in that case, <code>nano</code> will throw some errors and refuse to start. You have two choices in that scenario; first, disable that feature by deleting the corresponding line from <code>.nanorc</code> file. Your second option is to download the <code>nano</code> <a href="https://nano-editor.org/download.php">source code</a> and compile it yourself with all the features intact. If I were you, I'd go with the second option as compiling <code>nano</code> is really simple and straightforward. Only extra packages that you will need are <code>libncurses-dev</code> and <code>libmagic-dev</code>.</p>
<p>I'll leave you guys with a quote from some wise man,</p>
<blockquote>
<p>Good Things Come in Small Packages.</p>
</blockquote>
