Introduction to Nano Editor

Using Nano Editor

Go to a Specific Line in Nano Text Editor

Moving around in nano becomes easier when you could jump to any line.

There are two ways you can get to a specific line in the nano text editor:

  • Open a file with a cursor at that specific line using nano +n Filename where the n is the number of a line.
  • If you've already opened the file with the nano editor, then press Ctrl + / and enter the number of the line and it will land you on the entered line.

Want a detailed explanation? Here you have it.

Open a file to a specific line in the nano editor

This is what I personally use while debugging code as the error also points to the line where you made an error.

In simple terms, if you know on which line you want to make changes, this is what you should be using!

To use this method, you have to specify the number of a line while opening the file with the nano as shown:

nano +number_of_line Filename

For example, if I want to go to the 7th line in the sample.sh file, then I will be using the following:

nano +7 sample.sh
Go to specific line while opening the file using the nano editor

I would recommend using the -l flag which will add a number column to the left side indicating the line number:

nano -l +number_of_line Filename
go to specific line while showing the number of the file in the nano text editor

Go to a specific line in the Nano editor

If you want to go to a specific line within the nano editor, then you can follow the given steps:

  • Show the number of lines by pressing Alt + # (optional but helpful).
  • Press Ctrl + / to open a prompt to enter the number of the line.
  • Enter the number of the line and hit the Enter key.

Still confused? Let me show you how to pull that off:

Go to specific line within the nano editor

Pretty easy. Right?

More on the nano editor

If you are just getting started with the nano editor, you can refer to our beginner's guide to the nano editor:

Editing Files With Nano in Linux [With Cheat Sheet]
Though Nano is less complicated to use than Vim and Emacs, it doesn’t mean Nano cannot be overwhelming. Learn how to use the Nano text editor.

I hope you will find this guide helpful.