我经常在笔记本的中途意识到我忘了一个导入,然后想将它移到笔记本的顶部(我试图将大多数导入保存在那里)。有没有一种方法可以通过~/.jupyter/custom/custom.js
添加键盘快捷方式,将单元格移动到笔记本的顶部?
目前,我通过剪切单元格、滚动到笔记本顶部、粘贴并滚动回到原来的位置(通常在回程中会丢失我的位置)来实现这个功能。
下面是来自fastai论坛的代码,用于完成不同的任务:跳转到正在运行的单元格:
Jupyter.keyboard_manager.command_shortcuts.add_shortcut('CMD-I', {
help : 'Go to Running cell',
help_index : 'zz',
handler : function (event) {
setTimeout(function() {
// Find running cell and click the first one
if ($('.running').length > 0) {
//alert("found running cell");
$('.running')[0].scrollIntoView();
}}, 250);
return false;
}
});
command_shortcuts
表示该快捷键仅在命令模式下有效。 - user202729