24
  1. How to make ipython3 notebook show a vertical margin/marker line at 80 characters ?
  2. How to get i-bar location in ipython3 notebook ? (e.g. line 30 character 56)

These features assist in writing codes complying with PEP8. These features are available in Spyder.

Update 1: What I want is a vertical margin/marker line as shown in modified screenshot of the spyder. The other feature I am looking forward to is identification of location of i-bar. These two features are marked in the attached picture.

A similar solution is also okay. Modified screenshot of spyder

update 2: I did not find anything like this on the internet.

update 3: Jupyter Lab has a ruler setting (Sept 2020), details provided in the answer

Neeraj Hanumante
  • 1,575
  • 2
  • 18
  • 37

5 Answers5

13

This is Sept 2020. Version 2.2.8 of Jupyter Lab is available.

Answer 1: It provides a facility of a ruler in the Settings > Advanced Settings Editor. Answer by https://stackoverflow.com/a/55035981/6646912 gives general guidance on how to edit the settings. In particular, the following preferences can be included:

{
    "codeCellConfig": {
                        "rulers": [80],
                        "wordWrapColumn": 80,
                      },
}

Answer 2: Location of i-bar is also available in Jupyter Lab

Neeraj Hanumante
  • 1,575
  • 2
  • 18
  • 37
3

Using jupyterlab version 3.3.0 the Advanced Settings Editor (Shortcut: Ctrl+,) has got a nice GUI and a ruler can be set easily under the header "Rulers".

Just click on "Add" and set the wanted number. The changes are applied immediately.

add ruler

mosc9575
  • 5,618
  • 2
  • 9
  • 32
  • Note: You'll find there are different options for `Notebooks` and `Text`; Within notebooks there are different options for markdown vs. code cells. – MRule Sep 29 '22 at 17:26
  • In version `3.6.4` there **is no** settings category "Rulers" and search for "ruler" leads to NO results (this appears to be a bug since there are in fact many "Ruler" settings). You need to *separately* go to `Notebook` and `Text Editor`, scroll down to "Rulers", click *add ruler*, then specify the character width. The ruler is nearly invisible on low-color-depth monitors and you may need to adjust brightness/contrast to see it. There is no way to adjust the color or style of the rule. – MRule Jun 24 '23 at 08:34
1

You should have a look at the Jupyter Nbextensions. They Provide some (unofficial) community-driven extensions, also the vertical line / ruler like requested. you can find the documentation on the ruler here. I really like to other tools there too, like code prettyfiers or 2to3 converter and execution timer.

As far as I know there is no option to show the column count, but you can show line numbers when pressing l while having focus on the cell (focus doesn't equal editing, get the focus with pressing esc.

Nico Albers
  • 1,556
  • 1
  • 15
  • 32
1

If you only need it for a handful of documents there is always:

#< ---- 20 char ---->< ---- 20 char --->< ---- 20 char ---><9 char->

Which isn't ideal, but much faster than installing extensions and/or changing config files. The last one is 9 to account for the initial comment character.

Aaron
  • 7,015
  • 2
  • 13
  • 22
0

For adding ruler in jupyter notebook, please have a look here. I haven't tried it though. Please let me know if this worked.

For the ibar, line numbers can be achieved - press Esc (or click on the left side of the cell where were see In [ ]: to enable the command mode and click letter 'l'.

KBN
  • 153
  • 1
  • 8