Marc Garcia
Marc Garcia

Reputation: 3497

How to disable auto-quotes and auto-brackets in Jupyter 5.0

I upgraded Jupyter to the latest vesion, 5.0, and it looks like my front-end configuration stopped working.

I don't understand why Jupyter comes with auto closing quotes and brackets by default, which I find pretty annoying. So, at each version I have to change the settings to disable it.

It used to work by creating a file ~/.jupyter/custom/custom.js and adding the next JavaScript code:

require(['notebook/js/codecell'], function (codecell) {
  codecell.CodeCell.options_default.cm_config.autoCloseBrackets = false;
})

I've read that since Jupyter 4 this code could be changed by:

IPython.CodeCell.options_default.cm_config.autoCloseBrackets = false;

But it looks like in Jupyter 5, the two previous options stopped working.

The documentation I found regarding the front-end configuration is not helpful (I'll be happy to improve it once I understand it):

http://jupyter-notebook.readthedocs.io/en/latest/frontend_config.html#frontend-config

Can anyone help me understand how to disable auto-brackets and auto-quotes in Jupyter 5 please?

This is the exact version I'm running:

enter image description here

Upvotes: 48

Views: 34076

Answers (4)

eliu
eliu

Reputation: 2479

Here is my 2 jpgs:

[step 1] Go to "Advanced Settings" under "Settings" in menu:

"Advanced Settings" under "Settings"

[step 2] Select the "Notebook" category, in the "User Preference" tab, add text as follows: (just follow the syntax shown in the "System Defaults" tab):

{
    "codeCellConfig": {
        "autoClosingBrackets": false,
    },   
}

add text as follows in the "User Preference"

FYI:

!jupyter --version

jupyter core     : 4.7.1
jupyter-notebook : 6.3.0
qtconsole        : 5.0.3
ipython          : 7.22.0
ipykernel        : 5.3.4
jupyter client   : 6.1.12
jupyter lab      : 3.0.14
nbconvert        : 6.0.7
ipywidgets       : 7.6.3
nbformat         : 5.1.3
traitlets        : 5.0.5

Upvotes: 5

ARHAM RUMI
ARHAM RUMI

Reputation: 533

You can simply got to Settings tab and uncheck Auto Close Brackets option to disable auto-complete or check it to enable auto-complete

Upvotes: 8

yeliabsalohcin
yeliabsalohcin

Reputation: 740

For JupyterLab visitors there is a "User Preferences" panel of the "Notebook" settings editor into which you paste & save:

{
  "codeCellConfig": {
    "autoClosingBrackets": false
  }
}

Open with Ctrl + , or via menu: SettingsAdvanced Settings Editor & click "Notebook"

Upvotes: 16

Marc Garcia
Marc Garcia

Reputation: 3497

It looks like it can be done by running in a notebook:

from notebook.services.config import ConfigManager
c = ConfigManager()
c.update('notebook', {"CodeCell": {"cm_config": {"autoCloseBrackets": False}}})

This creates a file ~/.jupyter/nbconfig/notebook.json with the content:

{
  "CodeCell": {
    "cm_config": {
      "autoCloseBrackets": false
    }
  }
}

After executing the Python command, or manually creating the file, restart your Jupyter notebook, and it should stop auto-closing quotes and brackets.

Upvotes: 64

Related Questions