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

Vim cell commands

Open stsievert opened this issue 6 years ago • 9 comments

It'd be nice if Vim bindings could while in the notebook cell mode (not editing a cell). i.e., dd deletes a cellandyy` copies a cell.

I keep on running into this bug from Jupyter notebook muscle memory. It'd be nice if installing this package meant that those keybindings were enabled (and yes, I could go into settings and change them all but this would be easier).

stsievert avatar Feb 07 '18 18:02 stsievert

Thanks for the suggestion, I like this idea.

How would you feel if they were a single letter? So I would make the following mappings: D: cut cell P: paste below Shift P: paste above Y: yank cell

My main reason for this is I grew tired of double letter commands with jupyter-vim-binding at times and like the quickness with single letter commands. I think I would be more inclined to make it 'D D' if there are other motions that we could do with D. For example if we had 'D J' delete the current cell and the cell below.

jwkvam avatar Feb 07 '18 20:02 jwkvam

I'd prefer the bindings to be the same as vim's actions for a single line. I don't need to learn another set of keybindings then.

Could we present a choice to the user? I think maybe a switch would be appropriate here.

stsievert avatar Feb 07 '18 20:02 stsievert

I think others also preferred Ctrl-O D D to just Ctrl-O D for that reason. Yea, a switch would be nice. I haven't looked into what user configs extensions can create yet. I'll take a look at some point.

jwkvam avatar Feb 07 '18 21:02 jwkvam

I'm really missing cell-level commands too.

I agree with @stsievert it's better them to be consistent with vim row-level bindings (at least by default). We're already using this bindings working with cells content, why use anything else on cell level?

I would mention gg / G and visual mode for selecting and moving multiple cells at once.

Also I would be happy to have double esc and ctrl + { switching editor to cell-mode.

imbolc avatar Mar 06 '18 05:03 imbolc

@imbolc Apologies for my delayed response and thanks for your feedback.

  1. I'm working on something to add this feature in as a setting, perhaps defaulting to the double commands. In the meantime, you should be able to add them with the advanced settings editor.

  2. Yes, I agree gg and G would be good to implement. I'll open a separate issue to track this.

  3. Would your issues with selecting and moving multiple cells be solved with improving the cut and paste shortcuts? If not, I'd like to make a new issue for this. Ah I think you are looking for shortcuts that will move the current cell or selected cells up or down? I think that would be pretty slick.

  4. Interesting idea. I'm not sure how easy the double escape would be. I think it may interfere with some of the existing handlers but I would need to investigate more. Is ctrl-{ a vim shortcut or are you referring to ctrl-[? Or are you saying you would like ctrl-shift-[ to go to cell-mode?

jwkvam avatar Mar 14 '18 07:03 jwkvam

  1. I personally would be completely satisfied with yy, dd, y add d with selected cells and p
  2. Sorry, I meant just ctrl-[

imbolc avatar Mar 15 '18 05:03 imbolc

I personally would be completely satisfied with yy, dd, y add d with selected cells and p

Same here. I would also suggest making yy and dd the default cell-level copy and cut commands to match with vim syntax, but a way to switch from that to just y and d for people who are interested would be nice. @jwkvam I understand the point you made above:

My main reason for this is I grew tired of double letter commands with jupyter-vim-binding at times and like the quickness with single letter commands.

However, one thing I ran into when I wasn't expecting this was something like this: I wanted to delete a cell, then scroll down with j and paste it down lower. I typed CTRL-o dd then held j to start scrolling, but what this did is delete the cell after CTRL-o d, then deleted the current line and line below it with dj. I think other people with vim muscle memory would run into issues like this too.

Thanks for the great work on this @jwkvam!

benlindsay avatar Mar 16 '18 03:03 benlindsay

Just found this issue after wanting this enough to go and do https://github.com/jwkvam/jupyterlab_vim/pull/28 :)

Since this is explicitly a vim extension I think we should stay as close as possible to vim muscle memory shortcuts and make it easy for people to customize if they want other commands. At least for me it'd majorly mess with my sanity if dd deleted two cells.

ah- avatar Mar 17 '18 22:03 ah-

Is it possible to "y3y" to yank three cells, and "p" to copy them. (the same goes with "d3d" where 3 is just some arbitrary number)

YHRen avatar Jan 09 '20 18:01 YHRen