'Line numbers for every cell in VSCode Jupyter Notebook Cells
In the normal Jupyter notebooks, we can add line numbers by pressing the L key after selecting the cell. All the subsequent cells for that notebook will have line numbers automatically.
But this is missing in VSCode. Every time a new cell is created, we need to select the cell and press the L key to enable the numbering for that cell which is very tiresome.
Is there a way to automatically enable line numbering for all the cells in the VSCode Jupyter notebook instead of manually pressing the L key for each and every cell?
Thank you.
Solution 1:[1]
In VS Code Jupyter Notebook, you can toggle line numbers by pressing L. The trick is to select the current cell first. You could select your cell by clicking in the blank area on the left margin of the cell (when it's selected the bar on the left turns blue). Now if you press L on your keyboard, you would be able to turn the line numbers on/off.
Solution 2:[2]
- Click on the blank area (left side of the cell).
- Press Shift + L.
Solution 3:[3]
As of 2021-01-04, this is sadly not possible.
Subscribe to the GitHub issue (Feature Request) Line Numbers - All Cells #1593 for updates.
Related: Line numbers should be enabled for current cell and subsequent cells when turned on #1659
Solution 4:[4]
Coming in v1.56: https://code.visualstudio.com/updates/v1_56#_toggle-line-numbers
You can now temporarily toggle the line numbers of a cell in the current session from the cell toolbar, or change the visibility of line numbers for all notebooks through the
notebook.lineNumberssetting.
Under the ... in the floating menu is a line number toggle. [The gif is too large for SO.]
Solution 5:[5]
I always try any combination with modifiers keys. Found out that pressing Shift + L enables the lines number for all the notebook at once
Solution 6:[6]
Adding to this as still comes out the top result for the problem without a proper solution.
Assuming you have the Jupyter Notebook extensions installed for VSCode, in version 1.62.3, you can go into the Settings (Ctrl+,) search for "line numbers" and find the option for "Notebook:Line Numbers" and toggle this on.
This will show line numbers for all code cells in the Notebook by default so no need to keep pressing L
Solution 7:[7]
I tried CTRL + A (outside cells): select all cells and right clicked "show cell line number". It displayed line number for every cell.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Ruben Helsloot |
| Solution 2 | Hadij |
| Solution 3 | Tom Hale |
| Solution 4 | |
| Solution 5 | Daniele S DShot92 |
| Solution 6 | user17571854 |
| Solution 7 | adheir |

