Atom/Sublime like Jupyter 中的多项选择 [英] Atom/Sublime like Multiple selections in Jupyter

查看:24
本文介绍了Atom/Sublime like Jupyter 中的多项选择的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何通过键盘快捷键在 Jupyter 笔记本中选择匹配的关键字?例如,在 Atom/Sublime 编辑器中,我可以在 mac 上点击 cmd + D(或在 Windows 上点击 Ctrl + d),而光标在var"上,每个当我这样做时,下一个var"将被突出显示.然后我可以输入新的变量名,'var' 被替换为我输入的任何内容.

How can I select matching keywords in a Jupyter notebook via a keyboard shortcut? For example, in the Atom/Sublime editor I can hit cmd + D on a mac (or Ctrl + d on Windows) while the cursor is over 'var' and each time I do that the next 'var' will be highlighted. I can then type the new variable name and 'var' is replaced with whatever I typed.

var = "hello"
print(var)
print(var)

Jupyter notebook 中是否有类似的东西?

Is there an equivalent in a Jupyter notebook?

推荐答案

custom.js 添加到

C:Usersusername.jupytercustom      # for Windows and 
~/.jupyter/custom/                     # for Mac 

有内容

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) {}
            });
        }
    } 
);

并重新启动 jupyter.现在 Ctrl+D 应该像在 Sublime 中一样工作.

and restart jupyter. Now Ctrl+D should work like it does in Sublime.

您可以看到 Ctrl-Enter 功能被禁用,因为它非常方便地运行当前单元格而不是为大多数用户创建新行.您可以通过注释该行来选择具有该功能.

You can see that Ctrl-Enter functionality is disabled as it would be very convenient to run current cell rather than creating new line for most users. You can choose to have that functionality by commenting that line out.

您可以以类似的方式禁用您不想要的其他关键配置.

You can disable other key config that you don't want in a similar way.

这篇关于Atom/Sublime like Jupyter 中的多项选择的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆