Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
417 views
in Technique[技术] by (71.8m points)

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

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...