No matter what I do pasted line endings have ^M
in neovim in WSL.
This is my .vimrc
:
set clipboard+=unnamedplus
" WSL yank support
let s:clip = '/mnt/c/Windows/System32/clip.exe' " change this path according to your mount point
if executable(s:clip)
augroup WSLYank
autocmd!
autocmd TextYankPost * if v:event.operator ==# 'y' | call system(s:clip, @0) | endif
augroup END
endif
set ff=unix
The set ff=unix
seems to have no effect ?
Pasting into nvim from system clipboard from windows has ^M
Pasting into nvim using Ctrl+Shift+V does not have ^M
Yanking line in nvim using y
then pasting it with p
adds a ^M
as ending.
I know this has been asked before, but I cannot seem to get existing solutions to work.
According to :h clipboard-wsl
the suggested way of setting the WSL clipboard is:
Vimscript:
let g:clipboard = {
\ 'name': 'WslClipboard',
\ 'copy': {
\ '+': 'clip.exe',
\ '*': 'clip.exe',
\ },
\ 'paste': {
\ '+': 'powershell.exe -NoLogo -NoProfile -c [Console]::Out.Write($(Get-Clipboard -Raw).tostring().replace("`r", ""))',
\ '*': 'powershell.exe -NoLogo -NoProfile -c [Console]::Out.Write($(Get-Clipboard -Raw).tostring().replace("`r", ""))',
\ },
\ 'cache_enabled': 0,
\ }
Lua:
vim.g.clipboard = {
name = 'WslClipboard',
copy = {
['+'] = 'clip.exe',
['*'] = 'clip.exe',
},
paste = {
['+'] = 'powershell.exe -NoLogo -NoProfile -c [Console]::Out.Write($(Get-Clipboard -Raw).tostring().replace("`r", ""))',
['*'] = 'powershell.exe -NoLogo -NoProfile -c [Console]::Out.Write($(Get-Clipboard -Raw).tostring().replace("`r", ""))',
},
cache_enabled = 0,
}
As you can see, this removes that extra character.
Hope that helps.