WSL2 Copy Paste
When yanking text in WSL vim, it does not automatically transfer over to the windows clipboard. To do this there is a workaround to use vim-gtk and x server for windows
Install VIM GTK
VIM GTK is needed because the default vim installation does not have clipboard installed by default.
$ sudo apt install vim-gtk
X server for Windows
- Download and install from https://sourceforge.net/projects/vcxsrv/
- During the installation, enable the following:
- Multiple windows
- Start no client
- Extra Settings
- Clipboard
- Primary selection - Native opengl - Disable access control
- Save your configuration
- Copy the configuration to:
C:\Users\<yourawesomename>\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup
WSL2 setup
In your wsl terminal, execute these commands to integrate the x server
$ LOCAL_IP=$(cat /etc/resolv.conf | grep nameserver | awk '{print $2}')
$ export DISPLAY=$LOCAL_IP:0