Skip to main content

Additional Nano Tips

Go to a Specific Line in Nano

Don't jump to conclusions. Instead, learn to jump to the desired lines in Nano editor.

While you can move in the Nano editor using the arrow keys and page up/down keys, it's not very effective when you want to go to a specific line. This is specially the case when you are working on a huge text file.

In this quick Nano tutorial, I'll share a few tips on how you can jump to a certain line number:

  • Use nano +n file to open a file with cursor at line number n
  • In the Nano editor, press Ctrl+/ or Ctrl+shift+_ keys and enter line number to move to the line

Let's see it in detail with examples.

Open a file with cursor at specific line in Nano

This is simple. If you already know which line number you want to go to, open it with Nano in this manner:

nano +n filename

And it will open the file with cursor at the give line number n.

Open nano editor at specified line

But you will rarely know where to go when you are editing a file. The next method is more appropriate.

Go to specific line from within Nano editor

So you have a text file already opened and you realized that you have to go to a particular line number.

All you have to do is to press the Ctrl+/ or Ctrl+Shift+_ keys and it will prompt you to enter a line number. Provide the line number and press the enter key. The cursor position jump to this new line number.

Press Ctrl+Shift+_ and then provide the line number

I am displaying line numbers in Nano so that it is easy to follow the example.

Here's the same in action:

Go to a particular line in Nano
Press Ctrl+Shift+_ and then enter the line number

As you can see, it is easy to jump to lines in Nano if you know the correct keyboard shortcuts.

While they are displayed at the bottom and can be accessed in detail with the Ctrl+G keys, it is not always obvious and easy to understand.

And hence I wrote this quick tutorial to help you with it.

Abhishek Prakash