Skip to content
Home » Enable row numbers in Jupyter notebooks

Enable row numbers in Jupyter notebooks

  • by
  • 2 min read
Tags:

Various SaaS notebook solutions have row numbers enabled by default. It’s a pity that this is not the case within Jupyter. In this blog post, two ways to enable row numbers in Jupyter notebooks.

Enable row numbers via hotkeys

You can enable row numbers in one code cell by pressing L while the cell is not active.

You can enable row numbers in all code cells by pressing Shift + L while no cell is active.

If you cannot remember these hotkeys, open the command palette by pressing Control + Shift + P and search for ‘line numbers’.

Enable row numbers via notebook.json

In your Jupyter home directory you will find a folder nbconfig that contains a (hidden) file named notebook.json.

💥 Read here how you can display hidden files in Linux and in Windows.

💥 If you don’t know your Jupyter home directory, use the following command in a terminal.

jupyter --config-dir

You should edit the notebook.json file so that “lineNumbers” is set to true. A file without any other settings will look like this.

{
  "CodeCell": {
    "cm_config": {
      "lineNumbers": true
    }
  }
}

Great success!

Say thanks, ask questions or give feedback

Technologies get updated, syntax changes and honestly… I make mistakes too. If something is incorrect, incomplete or doesn’t work, let me know in the comments below and help thousands of visitors.

Leave a Reply

Your email address will not be published. Required fields are marked *