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.
How to Show Line Numbers in Nano? [Nano Line Numbers]
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
Conclusion
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: