2/28/2024 0 Comments Instal the new CopyClip 2![]() If you haven't set up a localhost SSH server on your WSL already, here's a quick overview of how: Putty/Kitty require an SSH server available in WSL, on a custom localhost port. We can connect to the WSL (or any of your other servers) using SSH via localhost, using a custom port, and get a fuller featured terminal, including almost all Vim capabilities for bi-directional, or native pasting, scroll, etc. Putty, or it's extended fork Kitty, offer a more robust terminal compared to WSL. This is not a direct WSL solution, rather a workaround using a better terminal + SSH until MS provides a fix. Nothing I tried as of April 2018 worked for pasting into Vim or other areas (using normal saneness) so, let's try to bypass the issue, and others related like buffer, for now. There are lots of quirks with WSL terminal, but using cross Vim copy/paste is top annoyance in my book. Finally, you need 2 s: one to execute the command and one get out of the subshell. Using ! means it's an external command, which is clip.exe here. Then :w will pass the selection to a command. : gets you into command mode ( which will give you '). Highlight text in visual mode and press Ctrl- c. Old Solution that Only Copied Whole Lines Mapping vnoremap ::w !clip.exe Finally, insert all that and use clip.exe to pass the entire thing to clip.exe. Then use escape to convert any !, %, or # characters to \!, \%, or \#, respectively. Then substitute out the newline characters with carriage returns using substitute. Then, use shellescape to handle the quotations. Then insert it into the command line using getreg('"'). ![]() Highlight text in visual mode (visual, visual line, or visual block) and press Ctrl- c. Here's a simple 2023 solution with no third-party software: Updated Solution Mapping vnoremap y:!echo =escape(substitute(shellescape(getreg('"')), '\n', '\r', 'g'), '#%!') clip.exe vimrc file.Īs robbiev mentions you should now also be able to use the Windows clipboard from remote machines using SSH X forwarding. Now you can access the Windows system clipboard via "*p and "*y, or set it to default by putting set clipboard=unnamed in your. If you don't have clipboard support, install a vim package compiled with clipboard support, e.g. Also if you run the ex command :echo has('clipboard') in vim and it says 0 it does not have clipboard support compiled in. vim -version | grep clipboard should say +clipboard, not -clipboard. bashrc in bash for Windows and run source ~/.bashrc in any open terminal.Įnsure vim is installed using clipboard support. Put export DISPLAY=localhost:0.0 in your. Go with all the defaults options, and ensure the clipboard options are checked.Īt the end, save the configuration to a file, config.xlaunch ( use that to start it from now on). Start it using the newly installed program XLaunch ( search in the start menu).Install VcXsrv (if it starts after installing, stop it).This solution worked for me, thanks to github user robbiev.įor completion this is an outtake from his answer: Let s:clip = '/mnt/c/Windows/System32/clip.exe' " change this path according to your mount pointĪutocmd TextYankPost * if v:event.operator =# 'y' | call system(s:clip, | endif vimrc (at the bottom, for example): " WSL yank support (Original answer) If you just want to yank from VIM to Windows, for WSL2 and Ubuntu 20.04, this answer on Reddit worked perfectly for me with standard VIM and standard WSL2 Ubuntu. Put win32yank.exe somewhere in your path on Linux (anywhere should be fine), and add the following to your init.vim. (Edit: Oct 2020) For 2-way clipboard on neovim, I have been using win32yank for several months with no issues.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |