Ruler

This extension enables the Ruler CodeMirror feature

Configuration

You can set the number of characters in the notebook extensions configration page or use the ConfigManager:

from IPython.html.services.config import ConfigManager
ip = get_ipython()
cm = ConfigManager(parent=ip)
cm.update('notebook', {"ruler_column": [80]})

CSS patch

Notebook versions from 4.3.0 through 5.1.0dev show up a bug in their CodeMirror CSS padding which causes the ruler to be misplaced (see jupyter/notebook#2869 for details). This nbextension introduces a css patch to attempt to correct this, but if it causes problems for you, you can disable it by setting the ruler_do_css_patch config key to false.

Multiple Rulers

To specify multiple rulers, set the ruler_column to a list of values, for example

cm.update('notebook', {"ruler_column": [10, 20, 30, 40, 50, 60, 70, 80]})

A separate color and style can be specified for each ruler.

cm.update('notebook', {"color": ["#000000", "#111111", "#222222", "#333333", "#444444",
                                 "#555555", "#666666", "#777777", "#888888", "#999999"]})

Creating a repeating pattern for either color or style is as simple as giving a list shorter than the total number of rulers

cm.update('notebook', {"ruler_column": [10, 20, 30, 40, 50, 60, 70, 80]})
cm.update('notebook', {"color": ["#FF0000", "#00FF00", "#0000FF"]})
cm.update('notebook', {"style": ["dashed", "dotted"]})

will result in red, green, blue, red, green, blue, red, green, blue, red and alternating dashed, dotted

See here for other line styles.