lambdalisue / jupyter-vim-binding

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

Yank (Y) doesn't work as expected #88

Closed buzypi closed 7 years ago

buzypi commented 7 years ago

Summary

When you yank a link in Vim using Y and press p, it pastes the entire line that the cursor is currently in the next line and positions the cursor in the newly created line.

Step by step procedure

  1. Insert a cell
  2. Click in the cell
  3. Press i
  4. Type a sentence like "The quick brown fox jumps over the lazy dog"
  5. Press Escape
  6. Press Y
  7. Press p

Actual

A part of the line gets copied in between the existing line.

Expected

The entire line should get copied in the next line and the cursor must be positioned in the new line.

Remarks

Thanks for the binding. :)

lambdalisue commented 7 years ago

Use yy instead of Y or remap Y to yy while

lambdalisue commented 7 years ago

Please close the PR if you are satisfied with my answer or give me a good reason to follow the native Vim's mapping :+1: .

buzypi commented 7 years ago

That sounds reasonable. I didn't know yy works.

dsummersl commented 7 years ago

Personally I've found the non-standard behavior of CodeMirror to vim/vi behavior of Y quite interrupts my workflow. Anyone have a snippet they could share to change this setting for jupyter (completely understand not wanting to deviate from CodeMirror's mappings)?

dsummersl commented 7 years ago

Here it is for posterity:

// Configure CodeMirror
require([
  'nbextensions/vim_binding/vim_binding',   // depends your installation
], function() {
  // Map Y to yy
  CodeMirror.Vim.map("Y", "yy", "normal");
});

(And restart your notebook, which I forgot to do. woops! 😸 )

lambdalisue commented 7 years ago

Please feel free to edit https://github.com/lambdalisue/jupyter-vim-binding/wiki/Customization 👍

dsummersl commented 7 years ago

done, thanks!