Skip to main content

It's 2021. The OP's question is still valid, but many of the answers here are for an older version of nano. I'm not presenting this answer as "the last word" - only as an update.

The default screen of nano consists of five areas. From top to bottom these are: the title bar, a blank line, the edit window, the status bar, and two help lines.

Where to display line numbers?

Line numbers may be displayed in one of two places:

  1. the edit window
  2. the status bar

The status bar display simply updates the line number (and column) of the cursor/insertion point as it's moved about in the edit window. Line numbers in the edit window are positioned in the left margin. It is possible to display the line number in either or both the edit window and the status bar.

Display line numbers in the edit window:

There are several methods (this is not necessarily a complete list):

1. before the file is opened:

Edit/create the file ~/.nanorc with the following line:

set linenumbers

2. when the file is opened:

Use the -l option in nano:

$ nano -l <myfilename>

3. after the file is opened:

Toggle line numbers "on" and "off" w/ alt-shift-#:

altshift#

Display line numbers in the status bar:

1. before the file is opened:

Edit/create the file ~/.nanorc with the following line:

set constantshow

2. when the file is opened:

Use the -c option in nano:

$ nano -c <myfilename>

3. after the file is opened:

Toggle line number display in the status bar "on" and "off" w/ alt-shift-C (for Mac keyboard it's shift-esc-3):

altshiftC and (or shiftesc3 for Mac keyboard)

Summary

These all work as of today: Ubuntu 20.04, nano --version = GNU nano, version 4.8, although there are minor discrepancies in the documentation.

It's 2021. The OP's question is still valid, but many of the answers here are for an older version of nano. I'm not presenting this answer as "the last word" - only as an update.

The default screen of nano consists of five areas. From top to bottom these are: the title bar, a blank line, the edit window, the status bar, and two help lines.

Where to display line numbers?

Line numbers may be displayed in one of two places:

  1. the edit window
  2. the status bar

The status bar display simply updates the line number (and column) of the cursor/insertion point as it's moved about in the edit window. Line numbers in the edit window are positioned in the left margin. It is possible to display the line number in either or both the edit window and the status bar.

Display line numbers in the edit window:

There are several methods (this is not necessarily a complete list):

1. before the file is opened:

Edit/create the file ~/.nanorc with the following line:

set linenumbers

2. when the file is opened:

Use the -l option in nano:

$ nano -l <myfilename>

3. after the file is opened:

Toggle line numbers "on" and "off" w/ alt-shift-#:

altshift#

Display line numbers in the status bar:

1. before the file is opened:

Edit/create the file ~/.nanorc with the following line:

set constantshow

2. when the file is opened:

Use the -c option in nano:

$ nano -c <myfilename>

3. after the file is opened:

Toggle line number display in the status bar "on" and "off" w/ alt-shift-C (for Mac keyboard it's shift-esc-3):

altshiftC and shiftesc3 for Mac keyboard

Summary

These all work as of today: Ubuntu 20.04, nano --version = GNU nano, version 4.8, although there are minor discrepancies in the documentation.

It's 2021. The OP's question is still valid, but many of the answers here are for an older version of nano. I'm not presenting this answer as "the last word" - only as an update.

The default screen of nano consists of five areas. From top to bottom these are: the title bar, a blank line, the edit window, the status bar, and two help lines.

Where to display line numbers?

Line numbers may be displayed in one of two places:

  1. the edit window
  2. the status bar

The status bar display simply updates the line number (and column) of the cursor/insertion point as it's moved about in the edit window. Line numbers in the edit window are positioned in the left margin. It is possible to display the line number in either or both the edit window and the status bar.

Display line numbers in the edit window:

There are several methods (this is not necessarily a complete list):

1. before the file is opened:

Edit/create the file ~/.nanorc with the following line:

set linenumbers

2. when the file is opened:

Use the -l option in nano:

$ nano -l <myfilename>

3. after the file is opened:

Toggle line numbers "on" and "off" w/ alt-shift-#:

altshift#

Display line numbers in the status bar:

1. before the file is opened:

Edit/create the file ~/.nanorc with the following line:

set constantshow

2. when the file is opened:

Use the -c option in nano:

$ nano -c <myfilename>

3. after the file is opened:

Toggle line number display in the status bar "on" and "off" w/ alt-shift-C (for Mac keyboard it's shift-esc-3):

altshiftC (or shiftesc3 for Mac keyboard)

Summary

These all work as of today: Ubuntu 20.04, nano --version = GNU nano, version 4.8, although there are minor discrepancies in the documentation.

adding line# toggle keyboard shortcut for Mac keyboard
Source Link

It's 2021. The OP's question is still valid, but many of the answers here are for an older version of nano. I'm not presenting this answer as "the last word" - only as an update.

The default screen of nano consists of five areas. From top to bottom these are: the title bar, a blank line, the edit window, the status bar, and two help lines.

Where to display line numbers?

Line numbers may be displayed in one of two places:

  1. the edit window
  2. the status bar

The status bar display simply updates the line number (and column) of the cursor/insertion point as it's moved about in the edit window. Line numbers in the edit window are positioned in the left margin. It is possible to display the line number in either or both the edit window and the status bar.

Display line numbers in the edit window:

There are several methods (this is not necessarily a complete list):

1. before the file is opened:

Edit/create the file ~/.nanorc with the following line:

set linenumbers

2. when the file is opened:

Use the -l option in nano:

$ nano -l <myfilename>

3. after the file is opened:

Toggle line numbers "on" and "off" w/ alt-shift-#:

altshift#

Display line numbers in the status bar:

1. before the file is opened:

Edit/create the file ~/.nanorc with the following line:

set constantshow

2. when the file is opened:

Use the -c option in nano:

$ nano -c <myfilename>

3. after the file is opened:

Toggle line number display in the status bar "on" and "off" w/ alt-shift-C (for Mac keyboard it's shift-esc-3):

altshiftC and shiftesc3 for Mac keyboard

Summary

These all work as of today: Ubuntu 20.04, nano --version = GNU nano, version 4.8, although there are minor discrepancies in the documentation.

It's 2021. The OP's question is still valid, but many of the answers here are for an older version of nano. I'm not presenting this answer as "the last word" - only as an update.

The default screen of nano consists of five areas. From top to bottom these are: the title bar, a blank line, the edit window, the status bar, and two help lines.

Where to display line numbers?

Line numbers may be displayed in one of two places:

  1. the edit window
  2. the status bar

The status bar display simply updates the line number (and column) of the cursor/insertion point as it's moved about in the edit window. Line numbers in the edit window are positioned in the left margin. It is possible to display the line number in either or both the edit window and the status bar.

Display line numbers in the edit window:

There are several methods (this is not necessarily a complete list):

1. before the file is opened:

Edit/create the file ~/.nanorc with the following line:

set linenumbers

2. when the file is opened:

Use the -l option in nano:

$ nano -l <myfilename>

3. after the file is opened:

Toggle line numbers "on" and "off" w/ alt-shift-#:

altshift#

Display line numbers in the status bar:

1. before the file is opened:

Edit/create the file ~/.nanorc with the following line:

set constantshow

2. when the file is opened:

Use the -c option in nano:

$ nano -c <myfilename>

3. after the file is opened:

Toggle line number display in the status bar "on" and "off" w/ alt-shift-C:

altshiftC

Summary

These all work as of today: Ubuntu 20.04, nano --version = GNU nano, version 4.8, although there are minor discrepancies in the documentation.

It's 2021. The OP's question is still valid, but many of the answers here are for an older version of nano. I'm not presenting this answer as "the last word" - only as an update.

The default screen of nano consists of five areas. From top to bottom these are: the title bar, a blank line, the edit window, the status bar, and two help lines.

Where to display line numbers?

Line numbers may be displayed in one of two places:

  1. the edit window
  2. the status bar

The status bar display simply updates the line number (and column) of the cursor/insertion point as it's moved about in the edit window. Line numbers in the edit window are positioned in the left margin. It is possible to display the line number in either or both the edit window and the status bar.

Display line numbers in the edit window:

There are several methods (this is not necessarily a complete list):

1. before the file is opened:

Edit/create the file ~/.nanorc with the following line:

set linenumbers

2. when the file is opened:

Use the -l option in nano:

$ nano -l <myfilename>

3. after the file is opened:

Toggle line numbers "on" and "off" w/ alt-shift-#:

altshift#

Display line numbers in the status bar:

1. before the file is opened:

Edit/create the file ~/.nanorc with the following line:

set constantshow

2. when the file is opened:

Use the -c option in nano:

$ nano -c <myfilename>

3. after the file is opened:

Toggle line number display in the status bar "on" and "off" w/ alt-shift-C (for Mac keyboard it's shift-esc-3):

altshiftC and shiftesc3 for Mac keyboard

Summary

These all work as of today: Ubuntu 20.04, nano --version = GNU nano, version 4.8, although there are minor discrepancies in the documentation.

Source Link
Seamus
  • 3.9k
  • 2
  • 21
  • 49

It's 2021. The OP's question is still valid, but many of the answers here are for an older version of nano. I'm not presenting this answer as "the last word" - only as an update.

The default screen of nano consists of five areas. From top to bottom these are: the title bar, a blank line, the edit window, the status bar, and two help lines.

Where to display line numbers?

Line numbers may be displayed in one of two places:

  1. the edit window
  2. the status bar

The status bar display simply updates the line number (and column) of the cursor/insertion point as it's moved about in the edit window. Line numbers in the edit window are positioned in the left margin. It is possible to display the line number in either or both the edit window and the status bar.

Display line numbers in the edit window:

There are several methods (this is not necessarily a complete list):

1. before the file is opened:

Edit/create the file ~/.nanorc with the following line:

set linenumbers

2. when the file is opened:

Use the -l option in nano:

$ nano -l <myfilename>

3. after the file is opened:

Toggle line numbers "on" and "off" w/ alt-shift-#:

altshift#

Display line numbers in the status bar:

1. before the file is opened:

Edit/create the file ~/.nanorc with the following line:

set constantshow

2. when the file is opened:

Use the -c option in nano:

$ nano -c <myfilename>

3. after the file is opened:

Toggle line number display in the status bar "on" and "off" w/ alt-shift-C:

altshiftC

Summary

These all work as of today: Ubuntu 20.04, nano --version = GNU nano, version 4.8, although there are minor discrepancies in the documentation.