-
Notifications
You must be signed in to change notification settings - Fork 43
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
Make insert the default mode of Notebook cells. #13
Comments
This extension works by listening to every time you switch cells and when you do it runs all of the vim initialization code on the cell you've switched to: https://github.com/axelfahy/jupyterlab-vim/blob/c4e43f940ef4be4c961608b6192412d2f3a33d1f/src/index.ts#L61-L64 My guess is that doing this is resetting the mode. I wonder if adding an if statement checking if the cell is already in vim mode, and if so not setting the keymap would prevent this. |
Follow up. That is indeed true. You can get the behavior you want if you only set the cell keymap on creation. This is the default in my pr to jupyterlab adding notebook vim to core jupyterlab/jupyterlab#9068 which uses a different method of setting the cells to be vim. |
And how do i check if the cell is already in vim mode? I looked into src/index.ts and couldn't find this done anywhere and am completely unaware of the codemirror api (or even javascript :-)) |
I got ur suggestion working on my end by using a count variable that runs the vim-mode initialistion only if the count is 0. But now I am unable to move between cells using j-k in the normal mode (i have to use up-down only.) Any ideas? |
I think the easiest way will look somethign like this: (untested but I htink this is will wokr) if (editor.getOption('keymap') === 'vim'){
return
}else {
// whatever is currently done
}
This was me no so long ago :). Codemirror vim api here: https://codemirror.net/doc/manual.html#vimapi |
This is after the changes you made? Or is that a bug in the version of the extension you installed? |
I was able to debug the issue with you approach. Somehow this function which is responsible for motions definign switching between cell using j-k is not called if I do not reinitialise the cell . (line 84) Any ideas?? |
@ianhi
The way I did this is :
Something I am perplexed about is that the indicator variable is initialised to default value in the constructor. If all the cells are different objects of the class VimCell how does the value of the indicator variable propagates when we switch to a different cell?? I can share my code if you want. Thanks |
So I was able to make the default mode of code-mirror to be insert mode by simply changing You would need to make a development install. Make sure that nodejs version is recent( I was getting from conda nodejs 6.63 and had to update the nodejs to get the local install working. |
Presently, when I jump to a notebook cell, I always end up in the normal mode, even if that cell was in insert mode previously. Do you think it is possible to make the cell remember their states.
The text was updated successfully, but these errors were encountered: