![]() ![]() 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 |