Switching VcXsrv for WSLg to Get Clipboard Sharing in WSL 2
We'll go over everything you need to set up to get proper Linux clipboard support and bidirectionally share it with Windows.
The good news is WSLg likely works for you out of the box or close to it on
both Windows 10 and 11. You can run wsl.exe --version
from WSL and check for
WSLg version: <VERSION>
. Besides that, as long as guiApplications=false
isn’t set in your Windows user’s .wslconfig
file then you’re good to go with
no additional set up.
You should be able to copy / paste text as long as your WSL Linux distro has
xclip
or another Linux clipboard tool installed. If you’re using Vim or
Neovim you’ll also want to make sure clipboard
is set to unnamedplus
. This
instructs Vim to use your system clipboard, it’s not related to WSLg.
Keep in mind if you’re using the Windows Terminal you can always use CTRL + SHIFT + c/v
to copy / paste but that’s not really clipboard sharing. That’s
just using a Windows app to handle copy pasting and it happens that app is
running Linux tools in WSL. Proper clipboard sharing will let you yank
something in Vim with its y
mapping and let you paste it into Notepad in
Windows and vice versa.
That level of sharing is very useful. It lets you copy paste from native Linux apps or pipe things from a script into your system’s clipboard. I do these things a lot.
# Clipboard Sharing Before WSLg with VcXsrv
Since about 2017 I’ve been using WSL and then WSL 2. Since then I always used VcXsrv to enable bidirectional clipboard sharing between Windows and WSL. VcXsrv is an open source Windows X server which supports clipboard sharing too.
I liked this approach because it means native Linux tools like Vim, Neovim, tmux and others didn’t have to be configured to use a specific clipboard tool for WSL 2. This let my dotfiles be compatible with all operating systems without dropping in if conditions.
The only thing I configured with Vim / Neovim was setting
clipboard=unnamedplus,unnamed
to use the system’s clipboard. This works on
all operating systems and isn’t related to WSL.
# Why Switch?
VcXsrv wasn’t a problem but it did require quite a few steps to get working:
- Installing VcXsrv
- Configuring VcXsrv
- Setting up VcXsrv to start up when Windows started
- Configuring
.wslconfig
in Windows to disableguiApplications
(WSLg) - Configuring your WSL distro to set the
DISPLAY
in your shell
Here’s the commit from my
dotfiles
to remove the above, although I didn’t set guiApplications
in my public
dotfiles, I did have it set locally.
That’s kind of a lot of steps. Technically you only had to do it once and you were set but still, if that can be avoided nowadays with WSLg it’s worth a shot.
Why Did I Wait So Long?
I knew WSLg could do this and I tried it when it was first available but it never worked for me on Windows 10. Clipboard sharing simply didn’t work.
Also, VcXsrv worked well for many years. It never skipped a beat.
But, while updating my dotfiles I took this as an opportunity to investigate if the landscape has changed so I tried WSLg out again.
Testing Things Out
After applying this
commit
and removing guiApplications=false
in my Windows .wslconfig
file, I ran
wsl --shutdown
from PowerShell, opened a new WSL instance and everything
worked.
I also installed pacman -Syu xorg-xcalc
and ran xcalc
to test a graphical
app and it worked.
# Is WSLg Better?
It depends. For running both X and Wayland apps with GPU support, sure. It’s nice.
For clipboard sharing, as of May 2025 I would say VcXsrv is better but WSLg is good enough. I made the trade off for simplicity of setting things up mainly so it’s easier for others to use my dotfiles if they want.
VcXsrv automatically handled Windows line endings when pasting into Linux apps.
It converted CRLF into LF. That means you can paste into WSL with things like
p
in Vim and not worry about it. It “just worked”.
WSLg will add trailing ^M
characters whenever there’s a line break when
pasting from Windows. I opened an issue for it on
GitHub. Thankfully you can
always hit CTRL + SHIFT + v
with the Microsoft Terminal because it handles
converting line endings for you. It’s kind of annoying to have to think about
this but hopefully this will get fixed over time.
Keep in mind the above problem is only when pasting from Windows into Linux. If
you’re normally copy / pasting within Vim you can use y
/ p
without issues.
The video below demo some of the above topics.
# Demo Video
Timestamps
- 0:37 – Make sure WSLg is available and enabled
- 1:55 – Switching from VcXsrv to WSLg
- 2:53 – Bidirectional clipboard sharing demo
- 4:31 – Uh oh, Windows line endings with WSLg
- 5:41 – Is it a bug with WSLg?
- 6:02 – Opening up a GUI app in Linux as a test
Did you get clipboard sharing to work with WSLg? Let me know below!