Windows line endings (^M) are added when copying from Windows and pasting into Linux apps
Windows build number:
10.0.19045.0
Your Distribution version:
Arch Linux
Your WSL versions:
WSL version: 2.4.13.0
Kernel version: 5.15.167.4-1
WSLg version: 1.0.65
MSRDC version: 1.2.5716
Direct3D version: 1.611.1-81528511
DXCore version: 10.0.26100.1-240331-1435.ge-release
Windows version: 10.0.19045.5737
Steps to reproduce:
- Open Neovim
- Copy multiple lines of text from Windows
- Paste into Neovim using
pwhen in normal mode - Notice
^Mbeing displayed at the end of each line that has a line break
Here's multiple lines of text to use as an example:
Hello world
Here's a few lines of text
Yep, this is 3 lines
WSL logs:
No response
WSL dumps:
No response
Expected behavior:
The lines are pasted without Windows line endings.
Actual behavior:
The lines are pasted with Windows line endings.
Technically you can paste with CTRL+SHIFT+v using the Microsoft Terminal and it seems to strip or convert the line endings but in my opinion this should be the default behavior of the clipboard manager.
I used VcXsrv with WSL for around 8 years which had clipboard sharing and it handled this automatically. I never saw a Windows line ending when pasting into Vim, Neovim or any other Linux app that was able to read the system clipboard.
reporting that it happens to me too
I'm also experiencing this so I setup a workaround
Perhaps Neovim can use wl-clipboard directly.
Perhaps Neovim can use wl-clipboard directly.
I am already using wl-clipboard which is a Wayland clipboard manager on Linux, although the problem happens with xclip too.
I think you might have meant using clip.exe in which case it would likely work but that means modifying an application to work specifically with WSL 2 when it works with native Linux. That's a bad path to go down IMO if you need to modify apps to work with WSL 2. Plus it was solved 8 years ago with VcXsrv, so it can be handled internally with the tool that's responsible for bridging between WSL 2 and Windows.
Ideally we wouldn't need to adjust every Linux application for WSL workarounds.
Other clipboard sharing tools mentioned earlier handled this internally.
On Sat, Nov 1, 2025, 10:46 PM Muhammed Murad Çiftçi < @.***> wrote:
muradcift left a comment (microsoft/wslg#1326) https://github.com/microsoft/wslg/issues/1326#issuecomment-3476741482
The issue is caused by the carriage return. While Linux uses \n for line endings, Windows uses \r\n. If you add these commands to your init.lua file, it will be fixed.
vim.opt.fileformat = "unix" vim.opt.fileformats = "unix,dos"
— Reply to this email directly, view it on GitHub https://github.com/microsoft/wslg/issues/1326#issuecomment-3476741482, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAGGRI3IGLNNUV2ITHG4FG332UE2DAVCNFSM6AAAAAB3RGBTYCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTINZWG42DCNBYGI . You are receiving this because you authored the thread.Message ID: @.***>
" WSL paste fix
autocmd BufReadPost * call s:lastpos()
function! WslCleanup()
silent! exe "'[,']s/\r$//g"
endfunction
nnoremap p p:call WslCleanup()
this is the vimscript macro i use right know to hack my way around this problem