Closed patrick-kidger closed 1 year ago
Do the yank-to-system-clipboard and paste-from-system-clipboard commands work? Spacey to yank and Spacep to paste.
Nope; save behaviour as above.
They clearly get saved to some clipboard -- presumably the Ubuntu one -- as this system-yank/paste works within just Helix itself.
This does work in Windows 10/WSL2, but requires additional user configuration.
clipboard.rs
has several "system clipboard" checks, all of which will fail under WSL/Windows 10 without additional configuration:
WAYLAND_DISPLAY
variable set and wl-copy
/wl-paste
available.DISPLAY
variable set and xclip
available.win32yank.exe
available (only in source at the moment; not released, see #1912)it's important to note that Windows 10 WSL does not support X11/Wayland out-of-the-box, so it's no surprise that Helix system clipboard support isn't working without xclip
/wl-clipboard
in WSL2/Windows 10.
However, this can be configured to work in several different ways:
Under Windows 11, WSL supports X11 and Wayland with clipboard integration. Simply install xclip
OR wl-clipboard
packages and Spacey and Spacep will copy to/paste from the Windows clipboard (as well as the X11 or Wayland clipboard).
Under Windows 10, you will need to install a third-party X server that supports Windows clipboard integration. VcXsrv is one. To configure:
xclip
in WSLDISPLAY
correctly. In WSL2, that's typically export DISPLAY="$(hostname).local:0"
.As an alternative under Windows 10, you can also:
Believe it or not, I've just tested all three of these approaches.
Am I correct in thinking that
win32yank.exe
available (only in source at the moment; not released, see Reintroduce win32yank as a clipboard provider on Linux for WSL2 + Windows 10#1912)
means that, there is already something in motion that will fix this issue? In other words, should we just sit still and wait patiently for it to be fixed?
@nekodjin Well, sort of. All three options have external dependencies, but the one with the fewest dependencies for Windows 10 involves either building from source or waiting patiently, yes.
Side note -- Looking at the source, I think it's possible to implement the system clipboard on WSL in a way that "just works" with a standard Windows 10/11 installation with no additional dependencies. But that's going to require an additional code change if so.
Addressed by #1912
Addressed by #1912
I have an issue currently where I am able to copy from helix to system (Win10) but not the other way around. I just installed helix on my Ubuntu distro under WSL2 (latest version). Any ideas on how I can troubleshoot? Any command I can run to get info for you to troubleshoot?
Running latest WSL2 (which has support for running GUIs natively etc), do I need to install any extra dependency or is it supposed to work out-of-the-box?
Yeah, you need to install win32yank.
win32yank
Ok, thank you! This should probably be added to the installation instructions
Should I install it in WSL or on the Windows side? This issue seems to suggest that it currently has to be installed on windows (eg. by using scoop) but this reddit comment seems to suggest that doing so adds a latency.
--
I went ahead and installed scoop
, installed win32yank
with it, and restarted.
Now pasting from system clipboard works in Helix, but as described above there is a latency of 2-3 seconds for just a single line of text.
It's unclear if there is a better solution. https://github.com/neovim/neovim/wiki/FAQ#how-to-use-the-windows-clipboard-from-wsl suggests that if Helix is also installed in WSL, you can install win32yank
on the Linux side.
In researching this, I also came across the currently still open #7219. Installed wl-clipboard
via
sudo apt install wl-clipboard
fixed the issue for me.
Summary
As title. I don't see any obvious way to copy or paste from the Windows 10 clipboard when using Helix on Windows Subsystem for Linux (WSL) 2.
Reproduction Steps
When pasting:
hx
i
insert modeConversely, when selecting text inside Helix, I get the message "yanked main selection to system clipboard", but it cannot be pasted from the Windows environment. I assume it only gets as far as the wrapped Ubuntu.
In contrast Vim seems to handle this seamlessly. (Ironically I actually had to use Vim to copy-paste my
config.toml
in #2131.)Helix log
No response
Platform
Windows WSL2, Ubuntu 20.04
Terminal Emulator
Hmm, whatever the WSL2 default is. Sorry!
Helix Version
git describe
: 22.03-89-g450f3489;hx -V
: helix 22.05-dev (450f3489)