jupyterlab-vim icon indicating copy to clipboard operation
jupyterlab-vim copied to clipboard

Custom Key Bindings and Persistence Across Environments

Open redditur opened this issue 1 year ago • 1 comments

It's not clear to me how to apply vim remappings. There's a section here (https://github.com/jupyterlab-contrib/jupyterlab-vim/blob/main/modify-keybinds.md#vim-remappings) suggesting to modify such mappings in the Notebook Vim settings but it's not clear where exactly or what such a modification looks like. I can't find any examples in this repo or elsewhere.

I see this for the Notebook Vim settings:

{
    // Notebook Vim
    // @axlair/jupyterlab_vim:plugin
    // Notebook Vim Settings
    // *****************************

    // Notebook shortcut key bindings for switching from vim Normal mode to Jupyter Command mode
    // [missing schema description]
    "cmdModeKeys": {
        "escToCmdMode": true,
        "shiftEscOverrideBrowser": true
    },

    // Enabled
    // Enable/disable vim extension (may require a page refresh)
    "enabled": true,

    // Enabled in Text Editor
    // Enable/disable vim in text editors (may require a page refresh)
    "enabledInEditors": true,

    // Extra Vim Keybindings
    // [missing schema description]
    "extraKeybindings": []
}

What exactly needs editing here and how, if, for instance, I want to do something simple like ":imap jk <Esc>"?

It also seems to me that this extension is local to the environment it's installed in. Is it possible to have this extension "globally active" no matter which environment I'm running a notebook within. E.g. notebook extensions in jupyter --data-dir apply wherever a notebook is running. Is there an equivalent? I appreciate this might be a broader jupyterlab question.

redditur avatar Nov 23 '23 10:11 redditur

If you go to the Notebook Vim settings in the Settings Editor (as opposed to the advanced JSON Settings Editor), scroll down to Extra Vim Bindings and click Add, you should see the following interface. There are instructions below each textbox about what each field means. If you want to batch-create JSON settings, I would suggest creating one rule using the interface first before going into the JSON Settings Editor to use the first rule as template.

image

Note that remapping j or k in Notebooks is currently not supported and is a known limitation, because the extension is hard-coded to hijack those keys to enable navigation between cells. See #113.

The question/request to have global extensions would need to be filed upstream at the JupyterLab repo.

firai avatar Dec 15 '23 16:12 firai