DEV Community

Abel Lifaefi Mbula for Kali Academy

Posted on • Edited on

How to Customize the Nano Text Editor in Linux

Think about making your Nano more enjoyable? This is a step by step guide on how to do so.

By default, Nano looks ugly and most people fear or can’t use it at all and prefer to go for Vi/Vim or Emacs. Truth be told, these editors have some really great features. But, do you know that with a little effort you can have most of their features in Nano?

Let’s see how.

In-line customization

First thing first. You need to try/preview the customization before setting it permanently. Don’t you?

So, how does it work? Very simple. You just need to add option(s) when calling Nano on your terminal as this:

Alt Text

As you can see in the image above, we will be opening the fizzbuzz.py file with the mouse support enabled on the command line. It means that mouse clicks can be used to place the cursor, set the mark (with a double click), and execute shortcuts. By default, the mouse is not supported on the console.

Note: mouse support is not available on a full command line system.

Some other options are: -i (autoindent), -l (display line numbers to the left of the text area)...

Need to see other available options? Type man nano on the terminal.

Are you satisfied with these preview customizations? Now is the time to

Permanently set customization rules with .nanorc

What’s .nanorc? It’s a file that contains configurations for… Nano. Nano reads it on startup. There’s one global file located at /etc/nanorc. But you can also create one for your own in your home (run cd ~ if not in home) that will overwrite global configurations.

Let’s now create our own nanorc.

From the CLI, run nano .nanorc and add as many rules as you can following the example below:

Alt Text

Save the file by doing Ctrl + X and hint Y (for yes).

Notes:

  • You can see that I’ve added a . (dot) before the name of the file, I do so to make the file hidden.
  • For more info about nanorc, type man nanorc

From now on, if you open Nano all your setups will be taken into account.

Enjoy your editing with Nano!

Top comments (2)

Collapse
 
moopet profile image
Ben Sinclair

I think this would be better with a new tag, #nano, rather than using #vim and #vscode.

Collapse
 
bam92 profile image
Abel Lifaefi Mbula

Thanks for that, I've edited.