Command-line Option
The simplest way to enable line numbering in Nano is by using the `-l` or `–line` command-line option when opening a file. Here’s how you can do it:
First, we will display the content of the file name “filename.txt” using cat command in linux.
cat filename.txt
Now we will use option `-l` to get line numbers when we open file with nano editor.
nano -l filename.txt
or
nano --line filename.txt
This command will open the specified file in Nano with line numbers displayed at the left margin.
How to Show Line Numbers in Nano Editor?
Nano is a popular and user-friendly text editor available on Unix-based systems, known for its simplicity and ease of use. While Nano provides essential features for text editing, such as syntax highlighting and search functionality, showing line numbers by default isn’t one of them. However, it’s possible to enable line numbering in Nano, which can be particularly helpful for referencing specific lines or debugging code. In this article, we’ll explore different methods to show line numbers in Nano editor with multiple examples and their explanations.