Open jwkvam opened 6 years ago
Have you considered some sequences like:
V
- enable cell selection mode (i think it's pretty intuitive vim row = jupyter cell)j .. k
- select some cellsm
- enable moving mode, now m
used for marking cell as marknown, but I don't think a lot of people are using it in cell-selection mode in which we interested inj .. k
- move the cellsSo here would be only one key to remember - m
(move), if you're not comfortable with its redefining we can use something else like g
(grab).
I thought about that a little yes, I liked the idea of there being a visual mode. There are a couple reasons I wasn't a fan of it:
But basically because of those two reasons. It was much easier for me to implement this by adding a couple shortcuts.
Happy to hear more opinions though :)
Thanks for building this extension! I couldn't live without vim mode :)
I've been using https://github.com/lambdalisue/jupyter-vim-binding with old-style notebooks and was just about to try and figure out how to port some of the related commands over. See https://github.com/lambdalisue/jupyter-vim-binding/blob/master/lib/jupyter/shortcuts.js for everything available there.
In jupyter notebook I always just used shift-j/k to select some cells, dd to yank them and then p to paste them. All in "normal" mode, so not while editing a single cell but working on multiple cells. I've found that pretty intuitive, since it's exactly the same way as you'd move a text block in vim.
The other bit I'm really missing is reliable undo for cell deletetion. With jupyter-vim-binding I could just press u in normal mode and it'd bring back the last cell I've yanked, in jupyterlab I've more than once deleted a cell accidentally and it was just gone.
How about imitating https://github.com/matze/vim-move and using alt-j/k for moving cells?
Alt j/k sounds good to me. I think it makes a lot of sense. Unfortunately for me, I can't use them because I use alt for many shortcuts for my window manager. That shouldn't stop them from being useful for others though.
I tried to get that working but couldn't figure out why it wasn't. I released v0.5.0 with just the ctrl e/y bindings for moving cells. I'll take a look at it another time, or if someone else wants to implement alt j/k I'd be happy to merge. Otherwise I think the more general solution is to get a settings page.
@ah- Yea, I want to implement more of those shortcuts from jupyter-vim-binding. If you want to implement more of them, I'd be likely to merge. I basically just implemented the ones I used most often :)
@jwkvam I made <M-j>
(Alt-J) and <M-k>
working by copy-pasting existing configurations. Let me know if you prefer a pull request from me to add these two keys. I dropped the following lines next to those that defined 'Ctrl Y
" and 'Ctrl E'
mappings.
commands.addKeyBinding({
selector: '.jp-Notebook:focus',
keys: ['Alt J'],
command: 'notebook:move-cell-down'
});
commands.addKeyBinding({
selector: '.jp-Notebook:focus',
keys: ['Alt K'],
command: 'notebook:move-cell-up'
});
I'm so used to visual mode, anything short of the sequence v->j*|k* ->y|dd -> p
would probably feel suboptimal for ME.
In my opinion Ctrl-E and Ctrl+Y should not default to moving cells around because they're already very useful keybindings in vim. I very frequently accidentally switch cells around with those keys (intending to scroll the page), which can result in subtle bugs in the code (I often tap them subconsciously along w/ eg Ctrl-D, so sometimes I don't notice that the page didn't scroll).
I am thinking Ctrl-E and Ctrl-Y to move cells up and down respectively. The main reason, I was thinking those chords was that they don't seem very useful in JupyterLab. In vim they are used to move the view up and down.
Others that I considered were:
I already have it working, attached is a demo.
cc: @imbolc