1

I'm able to paste text to other application using CTRL + V.

But when I try :let @" = expand("%:p"), then paste it to the other application it will just paste my last normal yanked text, instead the path of the file.

How I can paste the file path to other application from vim?

P.S.

When I paste the path to the vim instance, I can paste it using "0p.

5
  • What register do you use for the clipboard? + or *?
    – D. Ben Knoble
    Jun 2, 2020 at 10:49
  • @D.BenKnoble I just press y to yank, I got no idea about + or *. How I can check what register I'm using?
    – zer09
    Jun 2, 2020 at 11:47
  • Try :help "+; there’s probably an easier way but I cannot remember off the top of my head.
    – D. Ben Knoble
    Jun 2, 2020 at 11:48
  • @D.BenKnoble I think I am using the +, I tried to look at :reg the yanked text is also on the "+.
    – zer09
    Jun 2, 2020 at 12:04
  • I also noticed when I y, the value of "", "0 and "+ changed to the yanked value, but when I do :let @" = expand("%:p") only the "" and "0 is updated while the "+ is not.
    – zer09
    Jun 2, 2020 at 12:09

1 Answer 1

2

Depending on which clipboard register is being used (+ or *), you can use

let @+ = ...

The reason it « just works » when you press y to yank is that there is an option that lets the default yanks also go to the clipboard. See :help 'clipboard'

1
  • Thanks! Actually I learned from your comment above on my question that I can change the @" to @+ :D. But the "" and "0 is not updated when I use @+, only the "+ is updated, but when I paste on the vim instance it will use the value on "+, It seems a little bit weird for me right now. Maybe soon I will know why. BTW thanks again for the help.
    – zer09
    Jun 2, 2020 at 12:25

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.