When I use Command + C / V to copy and paste on the Projector terminal, there is always leading c and tailing v.
Does anyone know how to avoid this?
Related
Problem definition
My goal is copy code from vim and paste to browser.
It doesn't work as expected "+y and "*y command.
I have tried each two commands and tried ctrl + v to another application, but nothing happened.
I don't know what's problem.
What I tried
I've already seen these.
How to make vim paste from (and copy to) system's clipboard?
How can I copy text to the system clipboard from Vim?
Not only these but also lots of another Q&As.
I have tried these but still doesn't work.
My environment
I'm using Windows 10.
And on windows, I installed Ubuntu 20.04 and using VIM.
Result of vim --version | grep 'clip' is here.
+clipboard
As you see, clipboard and xterm_clipboard option is enabled.
And as said another Q&A of links, I append set clipboard=unnamedplus into my vimrc file.
But the result did not change.
As I understand you want to copy from vim in WSL to Windows. Unfortunately WSL and Windows have different clipboards, but this is solvable. For example in order to copy file contents from WSL to Windows clipboard, you need to pipe file contents to clip.exe:
cat myfile | clip.exe
So in vim we can:
yank your selection
Drop to command line and type :! echo
Paste the selection with Ctrl + r "
Continue typing in the command line: | clip.exe
hit Enter and profit!
Probably it would be useful to write some autocmd for this in vimrc.
I know I need to copy into the " or * registers or something like that
Let's say I have one c program in one terminal running vim and another program in another terminal...
How do I copy a line between them?
Visually select the line you want to copy with V.
Hit "*y to yank the line into the * (clipboard) register.
Open the other terminal and vim inside it.
Hit "*p to paste or press i and then paste the info in there (like you would normally copy paste).
If this does not work then you may need to run vim --version and see if your copy of vim is compiled with a +clipboard. If it says -clipboard then you will need to install a version of vim that was compiled with clipboard. Results may vary when ssh-ing into a server.
Has anyone found a good way to copy all lines from VIM in cygwin?
I've tried yanking the lines but it doesn't go to windows clipboard. Any ideas?
This seems to be a solution but it is a lot of work for copy/paste:
http://vim.wikia.com/wiki/Using_the_Windows_clipboard_in_Cygwin_Vim
UPDATE:
this works:
echo 'put this on my windows clipboard' > /dev/clipboard
BUT doesn't work for me because I want to copy to clipboard while SSH'd into another machine. So echo'ing/cat'ing to /dev/clipboard will put it on the other machine's clipboard, not mine
There may be better ways, but here's how I do it:
Use visual mode to highlight lines to be copied to clipboard (From command mode, v, then navigate normally to highlight).
"+y
to copy to clipboard.
Since the question asks how to copy everything:
ggVG"+y
This is maybe not as easy as you wanted it to be, but here is how I usually do it myself:
:w
:!cat %
This will display your file, and you can copy it from there.
Using this command:
http://www.hypexr.org/bash_tutorial.php#vi
I'm able to use vim commands in the bash. But, what I'd like to do is copy and paste from that (bash) into vim and vice-versa.
I know there are other posts on here using the middle mouse button, but I use putty to connect to linux boxes, and the middle mouse performs a selection, just like the left click drag.
I'm not looking for something that will modify my windows clipboard. Selecting in vim is useful for transfering stuff to and from windows, but I'd like a solution that will work both through putty and using a direct terminal.
Thanks in advance...
I use the copy&paste feature in screen. ctrl-[ to enter copy mode and ctrl-] to paste. There are different buffers and the ability to dump to a file. It's pretty powerful. The default is to copy lines, but you can curtail by columns join display lines into a single copied line (and other options). And since you would likely already be in screen when you run vim, you would have the paste buffer available. I also have hooks to copy the buffer to/from the X clipboard.
I don't know if that can help you, but I have installed a utility called xclip, which shares the X11 clipboard with VIM. I mainly use it to copy and paste between instances of VIM running in different terminal windows.
I typically use xclip with the following mappings, which keep a very similar behaviour to the usual yank and paste commands, but using the clipboard:
nmap `yy :.w !xclip<CR><CR>
vmap `y :w !xclip<CR><CR>
nmap `p :.r!xclip -o<CR>
nmap `P :.-r!xclip -o<CR>
Use the * (or + in X Windows) registers to reference the system clipboard. Anything yanked-to or pasted-from those registers can be used to cooperate with other applications:
Cut/Copy examples
"*yy : copy current line to the system clipbard
gg"*yG : copy current file to the system clipbard
"*dd : cut current line to the system clipbard
etc, etc
Paste examples
"*p : paste the system clipbard
Or in insert mode:
i Ctrl+r *
Or
i Ctrl+r Ctrl+p *
(the last one pastes withouth formatting, useful to avoid those ugly pastes from the OS clipboard where each indented line appears more and more shifted)
You can copy from/to the clipboard in both vim and bash using ctrl + ins for copy, and shift + ins for paste.
As a favour, I'm compiling a number of videos on a DVD. They're all different resolutions, codecs and containers. To save myself sometime I thought I'd just bundle in MPC and have a batch script launch them. I was told they need an icon and since there's no way to make dynamic shortcuts in Windows using %CD%, as far as I could find.
Very simple batch script:
START "" "%cd%\MPC-HC\mpc-hc.exe" "%cd%\VideoFiles\01.mp4"
So I've tried a few BAT to EXE apps and found that they really just decompress the BAT and run it. They use %CD% as their temp folder which makes it impossible to launch from a disc.
So I found ExeScript and I can alter the temp directory... Only problem? The BAT then launches from there then, meaning%CD% is useless.
So once again I alter the batch file to sniff out the disc drive:
for %%a in (C D E F G H I J K L M N O P Q R S T U V W X Y Z) do if exist %%a:\01.exe
set rundir=%%a:
START "" "%rundir%\MPC-HC\mpc-hc.exe" "%rundir%\VideoFiles\01.mp4"
This works well enough (causes an error if disc trays are open or empty), however if the files are copied to the HDD, then it doesn't as it'll try to read from the CD. There's no way of knowing if it's being launched from a hard drive or disc.
At this point I'd even appreciate help on how to write something like this in C and avoid batch files all together (and thus the temp file mess).
I've solved this by putting on a version for from the drive and one for from the HDD. Easiest solution.
What about relative folder paths?
START "" "MPC-HC\mpc-hc.exe" "VideoFiles\01.mp4"
That should work on HDD and CD alike.