gpt4 book ai didi

ipython - 按 ctrl-enter 后如何使 ipython 不退出编辑模式

转载 作者:行者123 更新时间:2023-12-01 01:00:05 28 4
gpt4 key购买 nike

在 ipython 2.1.0 中,我们有编辑模式和命令模式。进入单元格后,ctrl-enter 将在原地评估单元格并关注当前单元格,但离开编辑模式。所以如果我需要继续编辑单元格,还有一个额外的“Enter”可以按下。
有没有办法让默认行为保持编辑模式?

最佳答案

您可以使用 IPython javascript API 来修改快捷方式。

如果您使用 IPython.keyboard_manager.edit_shortcuts.add_shortcut命令您可以更改 ctrl-enter 快捷方式以不更改焦点。

%%javascript

IPython.keyboard_manager.edit_shortcuts.add_shortcut('ctrl-enter', {
help : "run cell and keep focus", //This is optional
handler : function (event) {
IPython.notebook.execute_cell();
IPython.notebook.edit_mode();
return false;
}}
);
edit_shortcuts可以换成 command_shortcuts如果您需要编辑命令模式的快捷方式。

同样, add_shortcut可以换成 remove_shortcut如果您需要删除现有的快捷方式。

关于ipython - 按 ctrl-enter 后如何使 ipython 不退出编辑模式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24210857/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com