Skip to main content
Fixed command passed to -c, to yank all the lines from the piped file
Source Link
HerCerM
  • 155
  • 3
  • 9

(Alternatives to @Biswapriyo's correct answer)

Using win32yank.exe

Having the .exe in $PATH:

cat /path/to/file | win32yank.exe -i

Using Neovim

cat /path/to/file | nvim -c 'normal gg_vg_"+yZQ'ggVG"+yZQ' --headless -

Explanation

Neovim uses an external program to interact with the system clipboard, and this specific program varies among platforms. On Windows it uses win32yank.exe. The -c option allows to execute a command after the file is loaded, --headless makes Neovim run without a UI, and the trailing - indicates to read from standard input. So if you have Neovim already configured in WSL to work with the clipboard, this should also work (doing about the same as just directly calling win32yank.exe).

Configuring Neovim's clipboard in WSL:

https://github.com/neovim/neovim/wiki/FAQ#how-to-use-the-windows-clipboard-from-wsl

(Alternatives to @Biswapriyo's correct answer)

Using win32yank.exe

Having the .exe in $PATH:

cat /path/to/file | win32yank.exe -i

Using Neovim

cat /path/to/file | nvim -c 'normal gg_vg_"+yZQ' --headless -

Explanation

Neovim uses an external program to interact with the system clipboard, and this specific program varies among platforms. On Windows it uses win32yank.exe. The -c option allows to execute a command after the file is loaded, --headless makes Neovim run without a UI, and the trailing - indicates to read from standard input. So if you have Neovim already configured in WSL to work with the clipboard, this should also work.

Configuring Neovim's clipboard in WSL:

https://github.com/neovim/neovim/wiki/FAQ#how-to-use-the-windows-clipboard-from-wsl

(Alternatives to @Biswapriyo's correct answer)

Using win32yank.exe

Having the .exe in $PATH:

cat /path/to/file | win32yank.exe -i

Using Neovim

cat /path/to/file | nvim -c 'normal ggVG"+yZQ' --headless -

Explanation

Neovim uses an external program to interact with the system clipboard, and this specific program varies among platforms. On Windows it uses win32yank.exe. The -c option allows to execute a command after the file is loaded, --headless makes Neovim run without a UI, and the trailing - indicates to read from standard input. So if you have Neovim already configured in WSL to work with the clipboard, this should also work (doing about the same as just directly calling win32yank.exe).

Configuring Neovim's clipboard in WSL:

https://github.com/neovim/neovim/wiki/FAQ#how-to-use-the-windows-clipboard-from-wsl

Source Link
HerCerM
  • 155
  • 3
  • 9

(Alternatives to @Biswapriyo's correct answer)

Using win32yank.exe

Having the .exe in $PATH:

cat /path/to/file | win32yank.exe -i

Using Neovim

cat /path/to/file | nvim -c 'normal gg_vg_"+yZQ' --headless -

Explanation

Neovim uses an external program to interact with the system clipboard, and this specific program varies among platforms. On Windows it uses win32yank.exe. The -c option allows to execute a command after the file is loaded, --headless makes Neovim run without a UI, and the trailing - indicates to read from standard input. So if you have Neovim already configured in WSL to work with the clipboard, this should also work.

Configuring Neovim's clipboard in WSL:

https://github.com/neovim/neovim/wiki/FAQ#how-to-use-the-windows-clipboard-from-wsl