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.
In more details CTRL – M (or ESC ) bring you to command mode, then pressing the L keys should toggle the visibility of current cell line numbers. In more recent notebook versions Shift-L should toggle for all cells.
You can show or hide line numbers in your code. Here's how. On the menu bar, choose Tools > Options. Expand the Text Editor node, and then select either the language you're using or All Languages to turn on line numbers in all supported programming languages.
Start by setting any breakpoints you need by clicking in the left margin of a notebook cell. Then select the Debug Cell button in the menu next to the Run button. This will run the cell in a debug session, and will pause on your breakpoints in any code that runs, even if it is in a different cell or a . py file.
Show activity on this post. In the command pallet run the command: Notebook: Execute Above Cells . Create a keyboard shortcut (e.g., alt+A ). Then you are done.
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?
On the toolbar, there is a bottom named open the command paletee, you can click it and type in the line, and you can see the toggle cell line number here. In Jupyter Lab 2.1.5, it is View -> Show Line Numbers. Adding to ronnefeldt's accepted answer: Shift L toggles line numbers in all cells. This works in JupyterLab 1.0.0 and in Jupyter Notebooks.
The Notebook Editor makes it easy to create, edit, and run code cells within your Jupyter Notebook. By default, a blank Notebook will have an empty code cell for you to start with. While working with code cells, a cell can be in three states: unselected, command mode, and edit mode.
For the whole notebook, open the Command Palette (Ctrl+Shift+P) and run the Jupyter: Debug Current File in Python Interactive Window command. For an individual cell, use the Debug Cell adornment that appears above the cell. The debugger specifically starts on the code in that cell. By default, Debug Cell just steps into user code.
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.
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
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.lineNumbers
setting.
Under the ...
in the floating menu is a line number toggle. [The gif is too large for SO.]
I always try any combination with modifiers keys. Found out that pressing Shift + L enables the lines number for all the notebook at once
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With