Nano Show Line Numbers

The Nano Editor is the most famous text editor for the console after vi/vim. What makes it popular is the ease of use.

By default you will not see a gutter area with line numbers when you open a file with Nano, there are multiple ways in which we can enable line numbers in Nano, let's take a look at a few of them.


Using the --linenumbers or -l flag

    When you open a file, just add --linenumbers to it.

    nano --linenumbers datafile.txt

    or,

    nano -l datafile.txt
    nano show line numbers example
    Line numbers as displayed in Nano Editor

Toggle Line Numbers

    If you have already opened a file using nano, and you want to display the line numbers, then you can toggle line numbers as follows,

    On macOS

     Esc + n

    On Windows

    Alt + Shift + 3
    Alt + #
    Press Escape N on macOS to Toggle Line Numbers

Comments & Discussion

Facing issues? Have questions? Post them here! We're happy to help!