-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Command mode support #7
Comments
Hi @ejisoo thanks! I'm not sure exactly what you mean? I think of there being three modes in jupyterlab-vim
Are you referring to mode 1? This extension should work in both Normal mode and insert mode, and you can use the built-in shortcut extension for mode 1. If you have a suggestion for something to add though I'm all ears :) |
Yes, I'm referring to 1. My key mapping looks likes this:
I want to use the same Ctrl-D to delete cells in Jupyter command mode, but it's not working (probably because it's not a vim mode). The default jupyterlab-vim bindings work just fine, but I want to use the vimrc mapping consistently across Jupyter command and edit mode. |
Unfortunately these modes are pretty fundamentally disconnected. Each cell is it's own codemirror instance and this extension works by accessing the codemirror vim api. Basically codemirror vim mode maintains a dictionary of the mappings that is shared across all of the codemirror editor instances and this extension just modifies that dictionary. Jupyterlab then has its own whole set of commands that are totally separate. I don't think that there is an easy way to map vim commands to notebook commands. Or at the very least we would have to manually curate the mapping. Extensions can modify jupyter shortcuts, for example In the meantime you can get the behavior you want by using the keyboard shortcut settings and adding this shortcut:
|
I'm curious about this. This isn't won't be a bug with this extension but it probably is a bug somewhere, either in codemirror or in jupyterlab. Have you ever narrowed down when it works vs when it doesn't? |
I guess part of what you want is to not have to change the settings file in multiple places every time you want to add a new mapping? Maybe we could introduce a new option in vimrc settings where you specify the keys to be remapped, the vim remapping, and the jupyter command you want run. So your example could have fit into something like this:
this would require making some assumptions about what the desired selector is though. Or perhaps this could default to Pros:
cons:
|
My GitHub app notifications were off for some reason. I really appreciate you researching and brainstorming.
I conceptually knew that (but confused by the fact that even a vanilla Jupyter supports D, D for cut-cell) the two key bindings are different, but didn't know how separately they were implemented. So, thanks for the links. Like you said, there may not be an easy way to propagate key mapping customizations.
I'll try this instead. I would normally avoid having to change the setting in two places, but I guess it's like setting the clock on the microwave and the oven separately (honestly, I wish those were in sync at least..)
As a result, I would have to agree with this assessment. I think your extension is small and neat — it may be best if kept that way. Initially, I thought of your extension as (jupyter-vim)rc as opposed to jupyter-(vimrc) if that makes sense. |
I had to comment out that mapping because it was inconsistent. I'll screen record it when I get a chance. It's irrelevant to this issue, but have you tried the black hole register ( |
I think this is a known bug in codemirror's vim mode. See codemirror/codemirror5#6223 So it first needs to be fixed there, and then someone needs to open a PR to jupyterlab updating the codemirror version (instructions for such a PR here: jupyterlab/jupyterlab#8267 (comment)) |
Just left a comment on the codemirror issue for what I think the solution might be. Unfortunately, I don't have the mental bandwidth to try to fix it myself, but my hope is that it may just be a one line fix. So it may be worth your while to look into it. Though beware that the effort distribution on these sorts of things is apparently insanely heavy tailed... hence my reticence to look into it myself |
It actually deletes the cell rather than cut which has been opened as a bug jupyterlab/jupyterlab#4765
Thinking about this more it probably wouldn't be too hard. At least it would be so long as jupyter-commands had their own section in the settings. And there is a definitely a mental coherence to having the whole jupyterlab vim experience configurable via one settings file.
I really like this description btw
Another excellent and concise phrasing - you're on fire! It does make sense. I've actually never firmly determined to myself what I wanted this extension to be. Until I became aware of the efforts to integrate jlab-vim into jupyterlab-core I had toyed with the idea of making a new vim extension that incorporated vimrc and the system-clipboard-support and calling it some horrendous like I think the following would be ideal
It looks as though 1 is going to happen, 2 is a maybe (idk how jlab devs would feel about it), and 3 just feels more unlikely as it starts to add complexity that I don't think the jlab devs will want to directly support. Though I definitely could be wrong about that. In the case where 1+ 2 happen I think it would make sense to extend vimrc to allow configurability of the entire vim experience in jupyterlab |
hooray! the |
Awesome!
I'm curious to see and nervous about how long I need to wait until the extensions start (or stop) supporting 3. |
What I ended up doing is not so fancy.. I just need those keys for moving around the cursor in Markdown mode.
Then jumping to the next cell is the usual jupyterlab-vim's Ctrl-J.
Glad I don't remember trying and regretting it. Years ago, I used to use jupyter-vim-binding and I've been using jupyterlab-vim for as long as I remember.
Absolutely.
I really hope this happens. Until I knew about axelfahy's fork of jupyterlab-vim, I had been on jupyterlab 1.2 for a long time only to use the vim binding. I was so happy to find the fork and later vimrc. I don't have the skills and time to develop extensions sophisticated like these, so I'm really thankful that these are/were around. Back to the point, I would be thrilled to see it integrated into core for my peace of mind. |
Thanks for creating this extension. I can't believe I missed this extension before.
I was wondering if you thought about extending the mapping to work in command mode as well not just in edit mode.
The text was updated successfully, but these errors were encountered: