I know gvim -c [command] samaple.txt
might run command predefined in command body. How to paste text from windows clipboard at the end of sample.txt file?
2 Answers
As far as I know the clipboard cannot be accessed from the command line natively. So that's going to be the biggest problem here. If you put the data somewhere accessible like a text file you could certainly use [command]
to do the rest. Something like:
gvim +"let @\"= {someData}" +"normal! Gp" sample.txt
But, as Peter Rincker mentioned if vim is complied with the +clipboard
option this is actually quite possible:
gvim +"$put+" sample.txt
+
is a special register that points to the clipboard. $put+
"puts" the +
register at the end of the file.
-
If (g)Vim is compiled properly with
+clipboard
then the"+
register can be used. e.g.gvim -c '$put+
sample.txt` May 24, 2018 at 18:30 -
@PeterRincker That is a very good point. Hmm... I feel bad stealing your answer though. May 24, 2018 at 18:34
-
-
Powershell can do it, something like this:
Powershell -command Add-Type -AssemblyName System.Windows.Forms;[System.Windows.Forms.Clipboard]::GetText()
May 24, 2018 at 18:44 -
command
normal! G"+p
works fine under linux, but somehow under windows it paste at the last line after first character. What is going on?– llukeMay 24, 2018 at 19:07
"+
is a special register. It refers to system clipboard.
You can paste the content of windows clipboard into current cursor position by using the below command:
"+p