48

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

Marc Garcia
  • 3,287
  • 2
  • 28
  • 37

4 Answers4

63

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.

Marc Garcia
  • 3,287
  • 2
  • 28
  • 37
  • 3
    Since you found the answer and shared it here (and many are finding it useful) please go ahead and mark it as accepted. Thanks.' – Ram Narasimhan Jul 16 '18 at 14:31
  • 2
    If you're using JupyterLabs, the instructions are different: https://github.com/jupyterlab/jupyterlab/issues/3358#issuecomment-502325845 – yeliabsalohcin Jul 02 '19 at 10:14
  • 4
    OP asked about auto-quotes too... to do so just add to the json: "autoCloseQuotes": false – Jay Marm Apr 18 '21 at 02:27
  • Perfect! And you don't even need to run in a notebook: it can be a simple terminal python (useful when you have multiple kernels in multiple environments which do not all have jupyters). – Dr_Zaszuś Jun 25 '22 at 10:09
15

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"

yeliabsalohcin
  • 720
  • 1
  • 6
  • 14
7

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

ARHAM RUMI
  • 441
  • 5
  • 11
5

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
eliu
  • 2,390
  • 1
  • 17
  • 29