How to make ipython not leave edit mode after pressing ctrl-enter

In ipython 2.1.0, we have edit mode and command mode. After entering a cell, ctrl-enter will evaluate the cell in place and focus on the current cell, but leave editing mode. Therefore, if I need to continue editing the cell, press the 'Enter' key to press. Is there a way to force the default behavior to remain in edit mode?

+4
source share
1 answer

You can use the IPython API to change shortcuts.

If you use the command IPython.keyboard_manager.edit_shortcuts.add_shortcut, you can change the ctrl-enter key combination so as not to change the focus.

%%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, .

+4

Source: https://habr.com/ru/post/1544517/


All Articles