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

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

问题描述

如何通过键盘快捷键在Jupyter笔记本中选择匹配的关键字?例如,在Atom/Sublime编辑器中,当光标位于"var"上方时,我可以在Mac上按cmd + D(在Windows上为Ctrl + d),每次执行此操作时,下一个"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笔记本中是否有类似的东西?

Is there an equivalent in a Jupyter notebook?

推荐答案

custom.js添加到

C:\Users\username\.jupyter\custom      # 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.

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

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