DEV Community

Cover image for JIM'S definitive guide to using GNU-NANO
Jimmy
Jimmy

Posted on

JIM'S definitive guide to using GNU-NANO

Nano or GNU Nano is a text editor that comes with almost every Linux distro these days.Now according to Wikipedia, the original name of the editor was tip, but tot avoid naming conflicts, it was changed to Nano, in which nano is 1000 times awesomer than pico(yet another text editor).
If you would like to know more about the history then this Wikipedia link is your best friend.

Now until recently, I did not know of about any of these features until I stumbled upon the help section of the editor. Now if you’re like me and would not like to spend half a day figuring out how to get started here is my divinely definitive short guide to using the nano editor effectively.

If you do not have it installed, sudo apt-get install nano will do the trick if you’re on a Debian based system. To launch nano just go to your terminal and type nano with the file you’d like to edit or just start from scratch like a madman. Now a full list of these command can be accessed easily by going to CTRL + G.

Lets begin. Sometimes you will want to enable mouse support and turns out this can be done quite easily using ALT + M or by pressing the escape key and then M depending on your preferences. There you go, now it is possible to navigate to line 328 in your file using the mouse cursor, without the hustle and bustle of using the down key. The command can be quite useful for example, setting the encryption key in a GCP .boto file. God this was impossible to find.

For those developers who would like to see the number of lines of code they have written there is the ALT + # to take care of your self esteem. This is another handy one. It was one of the main reasons I stumbled upon those commands. Again you could press the escape key and then # depending on your preferences.

To cut a section of line and save it in the cutbuffer use CRTL + K and to uncut it, use CTRL + U. Another conundrum that you might be faced with might be, how do you highlight a section of the file. Well to do this, you set a mark using ALT + A that is, the beginning of the line you want to cut and using the mouse cursor click the end of where you want your operation to end. To completely delete or throw way the marked or highlighted line use ALT + DEL.

Now one major feature that is super useful these days while working with large files is syntax highlighting and NANO out of the box comes with it enabled(my version 3.2 at least has it). Now if you’re a psychopath who hates colors there is also a command to turn it off using ALT + Y. If you have a linter all set up to your preferred coding style, you could make use of it using ALT + B. The spell check could be put into good use using CTRL + B , if it is available.

In the spirit of keeping this document short, I am going to end it here. NANO does have other features but you would be better off to using a text editor like VS code or its clone VS Codium for full-blown development. The options listed here are for working with touch and go files.

Top comments (0)