lambdalisue / jupyter-vim-binding

Jupyter meets Vim. Vimmer will fall in love.
2.1k stars 136 forks source link

keymap proposal for more jupyter actions #26

Closed wilzbach closed 8 years ago

wilzbach commented 8 years ago

After having had a look at the available jupyter actions, I recognized that we miss the keymaps for quite a lot, while the following is not complete here comes a proposal for some (new) keymaps:

(this is about the command mode - some normal vim binding don't conflict)

"x", "jupyter-notebook:delete-cell"
"r", "jupyter-notebook:run-cell"
"shift-r", "jupyter-notebook:run-cell-and-select-next"
"ctrl-r", "jupyter-notebook:run-all-cells"
"ctrl-shift-r", "jupyter-notebook:run-all-cells-below"

Ctrl-R is sometimes mapped to reload, but we don't want to use this for Jupyter notebooks.

"ctrl-m", "jupyter-notebook:merge-cell-with-next-cell"
"ctrl-shift-m", "jupyter-notebook:merge-cell-with-previous-cell"
"shift-b", "jupyter-notebook:rename-notebook"
"shift-t", 'jupyter-notebook:toggle-all-cells-output-collapsed'
"ctrl-0", 'jupyter-notebook:restart-kernel'
"shift-0", 'jupyter-notebook:restart-kernel-and-run-all-cells'
"/", 'jupyter-notebook:find-and-replace'

(this doesn't work yet)

As mentioned - this is just a proposal, so I am happy to hear your feedback ;-)

lambdalisue commented 8 years ago

Thanks for proposal. This is my opinion. Even the mappings are in Jupyter's command mode. I think we should follow Vimmer way ;)

x : Delete cell

I feel x is for deleting a single character for now. Yes, you can delete a selected sentence or so on with x as well so I need to think more about this.

R : Run cell

No. r is for replacing so I don't really think this is a good idea. Additionally, most of mappings are already provided (Ctrl-/Shift-/Alt-Enter) so this mapping should be in custom.js. run-all-cells feature is missing so probably Ctrl-Shift-Enter would take the place.

                                                        *r*
r{char}                        Replace the character under the cursor with {char}.
                        If {char} is a <CR> or <NL>, a line break replaces the
                        character.  To replace with a real <CR>, use CTRL-V
                        <CR>.  CTRL-V <NL> replaces with a <Nul>.
                        {Vi: CTRL-V <CR> still replaces with a line break,
                        cannot replace something with a <CR>}

                        If {char} is CTRL-E or CTRL-Y the character from the
                        line below or above is used, just like with |i_CTRL-E|
                        and |i_CTRL-Y|.  This also works with a count, thus
                        `10r<C-E>` copies 10 characters from the line below.

                        If you give a [count], Vim replaces [count] characters
                        with [count] {char}s.  When {char} is a <CR> or <NL>,
                        however, Vim inserts only one <CR>: "5r<CR>" replaces
                        five characters with a single line break.
                        When {char} is a <CR> or <NL>, Vim performs
                        autoindenting.  This works just like deleting the
                        characters that are replaced and then doing
                        "i<CR><Esc>".
                        {char} can be entered as a digraph |digraph-arg|.
                        |:lmap| mappings apply to {char}.  The CTRL-^ command
                        in Insert mode can be used to switch this on/off
                        |i_CTRL-^|.  See |utf-8-char-arg| about using
                        composing characters when 'encoding' is Unicode.

Ctrl-m : Merge cell

Actually, already Shift-m provide a same feature. I think it is good idea to add Ctrl-Shift-m for merging with previous cell.

Shift-b : Rename notebook

I feel b for moving a cursor backward. How about Shift-r to rename the notebook while r for replacing?

<S-Left>        or                                        *<S-Left>* *b*
b                        [count] words backward.  |exclusive| motion.

<C-Left>        or                                        *<C-Left>* *B*
B                        [count] WORDS backward.  |exclusive| motion.

Shift-t : Toggle output

I feel t for searching a single character like f. How about zA which is used for toggle all folding in Vim?

                                                        *t*
t{char}                        Till before [count]'th occurrence of {char} to the
                        right.  The cursor is placed on the character left of
                        {char} |inclusive|.
                        {char} can be entered like with the |f| command.

                                                        *zA*
zA                When on a closed fold: open it recursively.
                When on an open fold: close it recursively and set
                'foldenable'.

Ctrl-0 : Restart kernel

Well I don't really think we need these feature while 0,0 show a prompt for restarting the kernel. Additionally, Ctrl-1, Ctrl-2, and Ctrl-3 are mapped for converting a cell type so I'm afraid miss type.

Shift-0 : Restart kernel and run all cells

If we have run-all-cells feature, do we need this?

/ : Find and replace

Sounds great!

wilzbach commented 8 years ago

How about zA which is used for toggle all folding in Vim?

(y)

But then maybe we should add zR too?

http://vimdoc.sourceforge.net/htmldoc/fold.html

Following this I would suggest za and zr to toggle the the output of a single cell.

How about Shift-r to rename the notebook while r for replacing?

Well in Jupyter's command mode r is not mapped, but I think on the long run we want to eliminate Jupyter's own command mode - so I am all for it ;-)

lambdalisue commented 8 years ago

Following this I would suggest za and zr to toggle the the output of a single cell.

Well does Jupyter has the function? Then I will :-) Prob zm, zM as well.

wilzbach commented 8 years ago

Well does Jupyter has the function? Then I will :-) Prob zm, zM as well.

Yep it is jupyter-notebook:toggle-cell-output-collapsed

lambdalisue commented 8 years ago

Ok. I'll work on this after refactoring :-)