lambdalisue / jupyter-vim-binding

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

<Plug> bindings not working #61

Closed elvis-sik closed 8 years ago

elvis-sik commented 8 years ago

Summary

My custom.js is read properly (because I can map the sequence fd to <Esc>). However, no <Plug> mappings seem to work.

Environment

With the mapping

  CodeMirror.Vim.map("gu", "<Plug>(vim-binding-_)", "normal");

in place, when I press gu in normal mode, the selected cell should change.

Actual

When I press gu in normal mode, nothing happens. Similarly for other bindings that use <Plug>.

Step by step procedure

  1. Set up custom.js
  2. Open notebook with a few cells
  3. Enter normal mode
  4. Press gu

    What you have done to solve the issue

This happens in Chrome 49.0 as well.

Remarks

What I actually wanted to accomplish is swapping gj with j and ditto for k.

lambdalisue commented 8 years ago

Can I see your full custom.js while swapping gj with j is what I did in my custom.js so should work.

elvis-sik commented 8 years ago

Sure, here it is

// Configure CodeMirror
require([
  'nbextensions/vim_binding/vim_binding',   // depends your installation
], function() {
  // Map jj to <Esc>
  CodeMirror.Vim.map("fd", "<Esc>", "insert");
  // Swap j/k and gj/gk (Note that <Plug> mappings)
 //  CodeMirror.Vim.map("j", "<Plug>(vim-binding-gj)", "normal");
  CodeMirror.Vim.map("k", "<Plug>(vim-binding-gk)", "normal");
 //  CodeMirror.Vim.map("gj", "<Plug>(vim-binding-j)", "normal");
  CodeMirror.Vim.map("gk", "<Plug>(vim-binding-k)", "normal");
  CodeMirror.Vim.map("gu", "<Plug>(vim-binding-_)", "normal");
});

I left k swapped and j not so that I know that both are behaving exactly the same (that is, when I press gj it goes one visual line down, and when I press j it goes one logical line down. Similarly, k goes one logical line up and gk one visual one.

Also I experimented setting random noise as escape-sequence (e.g. uu) just to be sure that my file was being properly read.

What happened was I could type uu to jump out of insert mode but the behavior of gj or j or k or gu for that matter was still the same.

lambdalisue commented 8 years ago

I see. Thanks for reporting. It seems a bug of the plugin (I didn't notice but my one has same problem as well). I'll fix it

lambdalisue commented 8 years ago

Fixed. Try a latest HEAD (3e4030da4d23094840baa6967b99b965bea4144b)

elvis-sik commented 8 years ago

Thank you very much @lambdalisue If it weren't for this plugin, I wouldn't use the Jupyter nb at all, thank you for your work!