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

萝らか妹 提交于 2019-12-20 18:01:05

问题


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:


回答1:


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.




回答2:


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"



来源:https://stackoverflow.com/questions/44216326/how-to-disable-auto-quotes-and-auto-brackets-in-jupyter-5-0

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!