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 2


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` Commented May 24, 2018 at 18:30
  • @PeterRincker That is a very good point. Hmm... I feel bad stealing your answer though.
    – Tumbler41
    Commented May 24, 2018 at 18:34
  • You have my blessing, please post it as your own Commented May 24, 2018 at 18:35
  • Powershell can do it, something like this: Powershell -command Add-Type -AssemblyName System.Windows.Forms;[System.Windows.Forms.Clipboard]::GetText() Commented 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?
    – lluke
    Commented May 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:


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.