Adds support for yanking to using system clipboard using the registers *
and +
. This will affect both the builtin fileeditor and jupyterlab_vim
I also recommend https://github.com/ianhi/jupyterlab-vimrc
Running "*y
or "+y"
will yank to the vim registers used by jupyterlab and populate the system clipboard with the yanked text. Note that it does not distinguish between the system *
and +
registers on which are often distinct on Linux.
In jupyterlab open the Settings Menu
then choose Advanced Settings Editor
(or open with ctrl+,
) and edit the vim-system-clipboard
settings.
p
as normal.jupyter labextension install jupyterlab_vim-system-clipboard-support
Firefox >= 63
Chrome >= 66
Edge >= 79
Opera >= 53
See: https://developer.mozilla.org/en-US/docs/Web/API/Clipboard/writeText#Browser_compatibility This will only work on browsers that have implemented the writeText method of the clipboardAPI. Currently only supports yanking to the system clipboard, for pasting you will need to use ctrl-v or Cmd-v.
Currently this doesn't support pasting from the *
or +
registers. This can be added by adding the paste
function in a similar manner to the yank function. A starting point is the paste function in codemirror/keymap/vim.js found here. Unfortunately per https://developer.mozilla.org/en-US/docs/Web/API/Clipboard/readText#Browser_compatibility this will not work on Firefox as it does not expose the clipboard.readText
api outside of browser extensions.
The jlpm
command is JupyterLab's pinned version of
yarn that is installed with JupyterLab. You may use
yarn
or npm
in lieu of jlpm
below.
# Clone the repo to your local environment
# Move to jupyterlab_vim-system-clipboard-support directory
# Install dependencies
jlpm
# Link your development version of the extension with JupyterLab
jupyter labextension install .
# Rebuild Typescript source after making changes
jlpm build
# Rebuild JupyterLab after making any changes
jupyter lab build
You can watch the source directory and run JupyterLab in watch mode to watch for changes in the extension's source and automatically rebuild the extension and application.
# Watch the source directory in another terminal tab
jlpm watch
# Run jupyterlab in watch mode in one terminal tab
jupyter lab --watch
jupyter labextension uninstall jupyterlab_vim-system-clipboard-support