Closed banderlog closed 1 year ago
Hi @banderlog currently this is available via a separate extension: https://github.com/ianhi/jupyterlab-vimrc#jupyterlab-vimrc
After pip install jupyterlab-vimrc
you yank to the system clipboard using "+y
and also have an option to set unnamedplus=True
in the settings. Unfortuantely this currently only works for yanking but not for pasting (see https://github.com/ianhi/jupyterlab_vim-system-clipboard-support/issues/2 for discussion of this)
It would be good to add registers support: https://www.davidbegin.com/10-vim-registers-to-rule-them-all/
This extension doesn't actually implement the vim keybindings it just changes some things in jlab so that the Codemirror vim mode (https://github.com/codemirror/CodeMirror/blob/master/keymap/vim.js) are applied and are modified slightly for the notebook context. I believe that they actually do implement a good number of the registers. But historically javascript was mostly prevented from writing to the system clipboard so that was never implemented.
From that file:
* Registers: unnamed, -, ., :, /, _, a-z, A-Z, 0-9
* (Does not respect the special case for number registers when delete
* operator is made with these commands: %, (, ), , /, ?, n, N, {, } )
* TODO: Implement the remaining registers.
@ianhi wow, thank you for jupyterlab-vimrc, I'll try it :)
I believe that they actually do implement a good number of the registers. But historically javascript was mostly prevented from writing to the system clipboard so that was never implemented.
But, please correct me if I am wrong, in jupyterlab-vim there are no registers at all (or just a single one). I mean that jupyterlab-vim does not use all implemented in vim.js features, i.e., registers.
But, please correct me if I am wrong, in jupyterlab-vim there are no registers at all (or just a single one). I mean that jupyterlab-vim does not use all implemented in vim.js features, i.e., registers.
Happily enough I think you may be mistaken here. At the very least the numerical registers work for me (only inside of jlab - never transfers to outside). THey should also work here: https://codemirror.net/demo/vim.html if they work on that demo and not in jlab then there is an issue with the extension.
Strange thing, with jupyterlab-vimrc and {"unnamedplus": true}
I was able to copy TO clipboard system register, but not FROM it.
Is there a way to do it in both ways?
Also, yankind anything to any number register will yank it to the number register AND the main one (unnamed register in vim)
THey should also work here: https://codemirror.net/demo/vim.html if they work on that demo and not in jlab then there is an issue with the extension.
On demo page stated that "Cross-buffer yank/paste" implemented. But actually it is not even able to yank to the system buffer as jupyterlab-vimrc do.
That is the reason: https://github.com/codemirror/CodeMirror/issues/6341
Looks like workable solution: https://github.com/codemirror/CodeMirror/issues/3075#issuecomment-612319694
But this solution above was proposed by you, author of jupyterlab-vimrc repo and actually included in it :))
I've created issue in jupyterlab-vimrc since it more probable that it will be implemented there: https://github.com/ianhi/jupyterlab-vimrc/issues/18
I did little research there, I am bad in JS and web development, but from my point of view it can't be done only in some sort of firefox extension, which is not looks like jupyter-lab friendly way.
Please correct me if I am wrong (still have a hope)
By the way, both copying and pasting from the system clipboard ("+y
and "+p
) are supported by the underlying vim engine (https://github.com/replit/codemirror-vim) in Chrome-based browsers, even without any additional JupyterLab extensions. (Attempting the first paste will ask you for permissions.)
Copying to the system clipboard (the +
register) is supported in Firefox. However, Firefox unfortunately does not allow Javascript to read/paste from the system clipboard, and it does not provide an accessible way to grant the permission to do so. The only workaround I'm aware of is to Ctrl+v in Insert mode.
So this is partly a "it's already implemented," if you aren't using Firefox, and partly a "there isn't anything we can do here," if you are using Firefox.
By the way, both copying and pasting from the system clipboard ("+y and "+p) are supported by the underlying vim engine
Oh wow, that's cool! Would it be possible to include an option to set this as the default register without rebdining every y
operation manually? Something like set clipboard=unnamedplus
in regular vim?
As mentioned above, I believe the original issue of not being able to use registers is already resolved for most cases, with the caveat that pasting from the system clipboard in Firefox can only be implemented upstream in Firefox. For clarity, the enhancement request for an option to set the +
register as the default register will be tracked in #79.
Or any other system buffers. To paste/copy something outside jupyterlab one still need to use CTRL+C/CTRL+V in inset mode with manual selection.
It would be good to add registers support: https://www.davidbegin.com/10-vim-registers-to-rule-them-all/
Or do something like
set clipboard=unnamedplus
(https://stackoverflow.com/questions/11489428/how-to-make-vim-paste-from-and-copy-to-systems-clipboard)