+1 (506) 500-5957 sales@monovm.com Get US VPS for 50% OFF!

How to Show Line Numbers in Nano Editor?

Do you wish you had Nano line numbers? Well, now you can; read on to find out how to show line numbers in Nano editor.

Posted: 28 Jan, 21 Updated: 10 Dec, 22 by Antoniy Yushkevych 2 Min

List of content you will read in this article:

The nano editor is a text editor included in many Unix-based systems. It is a small, lightweight editor that is easy to use and perfect for making simple changes to text files. If you're new to the nano text editor, you may wonder how to show line numbers in Nano. This can be helpful when working with long files or finding a specific line of code.

There are 4 methods to show line numbers in nano, and they are as follows:

Method 1:

You can directly use the following command to display line numbers in Nano:

nano --linenumbers [filename]

As below:

nano --linenumbers testfile.txt

Method 2:

You can press  Alt +Shift + 3 key combinations to display line numbers quickly.

Method 3:

You can compile Nano from scratch:

git clone git://git.savannah.gnu.org/nano.git;cd nano;./autogen.sh;./configure;sudo make install

nano ~/.nanorc

Then, in your /.nanorc file, add the following codes, do not worry if this file is empty. This file is not existed by default:

# include all the preexisting configs
include "/usr/share/nano/*.nanorc"
set linenumbers

Method 4:

You can use CTRL + C  to display the current line number.

Also, to display the line & column number, you could just add the -c parameter when running nano editor:

nano -c [filename]

As below:

nano -c testfile.txt

You can easily set line numbers in your nano editor using 4 methods. Line numbers are important for users to get references on which line they are working on. Enabling them will help them understand and find an error in any lines. In this article, we have explained nano show line numbers commands. If you have any questions, you can ask them in the comment box.

People are also reading:

Antoniy Yushkevych

Antoniy Yushkevych

Master of word when it comes to technology, internet and privacy. I'm also your usual guy that always aims for the best result and takes a skateboard to work. If you need me, you will find me at the office's Counter-Strike championships on Fridays or at a.yushkevych@monovm.com