jupyterlab-contrib / jupyterlab-vim

Vim notebook cell bindings for JupyterLab
https://jupyterlab-contrib.github.io/jupyterlab-vim.html
MIT License
660 stars 43 forks source link

ENH: add a setting to bind `esc` to `leave-current-mode` #101

Closed ianhi closed 9 months ago

ianhi commented 11 months ago

We should add a setting that allows binding Esc to leave-current-mode as proposed in #70

firai commented 11 months ago

~It seems like the search box Esc binding for JL 4.0.x that was added in #90 needs to be disabled in order for double duty Esc à la #70 to work in JL 4.0.x. As far as I can tell, closing the search box by Esc still seems to work in notebooks in JL 4.0.x without the extra search box binding, probably because of the .jp-mod-searchable-wide binding. I don't know what's going to happen in 4.1.x.~ EDIT: Removed in 4.0.3.

You can add the following to the shortcut bindings to enable this feature. The leave-insert-mode binding needs to be disabled if the following is added as a user preference and if one starts from the auto-generated shortcut bindings rather than blank settings. Obviously this would be done if it was done from the extension itself.

{
    "shortcuts": [

        // The additional settings start here
        {
            "args": {},
            "command": "vim:leave-current-mode",
            "keys": [
                "Escape"
            ],
            "selector": ".jp-NotebookPanel[data-jp-vim-mode='true'] .jp-Notebook.jp-mod-editMode"
        }
        // The additional settings end here

    ]
}
firai commented 9 months ago

A proposed implementation has been opened at #110. Comments are welcome.