在jupyter笔记本中禁用Ctrl + Enter sublime keymap

use*_*046 5 windows key-bindings codemirror sublimetext jupyter-notebook

我正在使用Jupyter Notebook和Sublime Text键映射,将以下内容添加到我的Jupyter custom.js中:

require(["codemirror/keymap/sublime", "notebook/js/cell"], 
function(sublime_keymap, cell) {
    cell.Cell.options_default.cm_config.keyMap = 'sublime';
});
Run Code Online (Sandbox Code Playgroud)

...主要是很好用,除了我在Windows机器上,这将"insertLineAfter"的Sublime功能添加到Ctrl + Enter的绑定中,我不想要这个,因为Ctrl + Enter是要执行的绑定Jupyter目前的单元格.

有谁知道如何禁用Ctrl + Enter的"insertLineAfter"绑定吗?

Wil*_*ers 7

以下为我工作:

require(["codemirror/keymap/sublime", "notebook/js/cell", "base/js/namespace"],
    function(sublime_keymap, cell, IPython) {
        cell.Cell.options_default.cm_config.keyMap = 'sublime';
        cell.Cell.options_default.cm_config.extraKeys["Ctrl-Enter"] = function(cm) {}
        var cells = IPython.notebook.get_cells();
        for(var cl=0; cl< cells.length ; cl++){
            cells[cl].code_mirror.setOption('keyMap', 'sublime');
            cells[cl].code_mirror.setOption("extraKeys", {
                "Ctrl-Enter": function(cm) {}
            });
        }
    } 
);
Run Code Online (Sandbox Code Playgroud)


小智 5

您可以通过注释掉以下行来防止 ctrl+enter 在 jupyter notebook 中生成新行:

cmds[map[ctrl + "Enter"] = "insertLineAfter"] = function(cm) { insertLine(cm, false); };
Run Code Online (Sandbox Code Playgroud)

在文件中:

[python lib path]/dist-packages/notebook/static/components/codemirror/keymap/sublime.js
Run Code Online (Sandbox Code Playgroud)


mat*_*tst 0

unbound可以使用文件中的命令禁用各个 Sublime Text 键绑定Default (OS).sublime-keymap。IE Menu --> Preferences --> Key Bindings - User。在您的情况下,只需添加以下行。

{ "keys": ["ctrl+enter"], "command": "unbound" },
Run Code Online (Sandbox Code Playgroud)

由于Add Line.sublime-macro非常有用,您可能希望给它另一个绑定,例如您可以使用alt+enter或者super+enter在这种情况下您将添加以下内容。

{ "keys": ["ctrl+enter"], "command": "unbound" },

{ "keys": ["alt+enter"], "command": "run_macro_file", "args": 
    {"file": "res://Packages/Default/Add Line.sublime-macro"} },
Run Code Online (Sandbox Code Playgroud)