lambdalisue / jupyter-vim-binding

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

Copy to clipboard functionality #4

Closed TyberiusPrime closed 8 years ago

TyberiusPrime commented 9 years ago

It would be nice if I could still copy to clipboard instead of just yaking within ipython notebook from the keyboard. Can't seem to find a keybinding for that.

lambdalisue commented 9 years ago

It would be nice for me as well but I don't know how.

lambdalisue commented 9 years ago

it seems impossible. most browser does not allow to access clipboard because of security reason.

TyberiusPrime commented 9 years ago

Yes, but if we manage to release ctrl-c back to it's default browser binding, we should have a regular copy event?

lambdalisue commented 9 years ago

Good point. I'll remove the line https://github.com/lambdalisue/jupyter-vim-binding/blob/master/nbextensions/vim_binding.js#L104

TyberiusPrime commented 9 years ago

I think something lower down is also hogging the shortcut :(

lambdalisue commented 9 years ago

It is a difficult topic. I don't have any compas to select which shortcut is necessary thus I just copied most of that from jupyter's default.

which one do you think "bad mapping"?

TyberiusPrime commented 9 years ago

All I know right now is that ctrl-c doesn't work for copy for me even if I remove that line. Ctrl-V in insert mode does work though - even though it works as visual selection in command mode.

lambdalisue commented 9 years ago

Hum.... In my case, C-V doesn't work as well. I'll check it

lambdalisue commented 9 years ago

Probably we have to end up for enabling system clipboard. It won't work in CodeMirror's Vim mode. While this plugin rely on CodeMirror's Vim mode, it is not possible to enable the system clipboard.

Although we are vimmer, we have to use a mouse to copy and paste text... Really inconvenient :angry:

lambdalisue commented 9 years ago

I think I found a compass https://github.com/LightTable/LightTable/issues/688

lambdalisue commented 9 years ago

Sigh. https://github.com/codemirror/CodeMirror/blob/master/keymap/vim.js#L1265

TyberiusPrime commented 9 years ago

I take it that's not just the input mode callback :(

lambdalisue commented 9 years ago

Anyway, this is a problem of CodeMirror so I close it.

TyberiusPrime commented 9 years ago

Not so fast with the closing, I found a way that works by disabling all ctrl-c binding, which then has the browser take over:

this.code_mirror.addKeyMap({"Ctrl-C": false});

lambdalisue commented 9 years ago

Well. It is good to know but while CodeMirror's default behavior disable Ctrl-C, I would like to follow that and that kind of trick should be performed by user.

But anyway, thanks to found the solution. I will add the tips to README.md later

lambdalisue commented 8 years ago

https://zenorocha.github.io/clipboard.js/

lambdalisue commented 8 years ago

Copy: http://stackoverflow.com/questions/9492842/does-codemirror-provide-cut-copy-and-paste-api How about paste?

lambdalisue commented 8 years ago

https://www.lucidchart.com/techblog/2014/12/02/definitive-guide-copying-pasting-javascript/

lambdalisue commented 8 years ago

Paste with p is prob. not possible http://jsfiddle.net/lambdalisue/bk2kfg4c/1/