What is the Vim command to copy content from a file (opened in Vim editor) and paste in Firefox browser address bar?

890 views Asked by At

I'm trying to copy a text (link) from my file (opened in vim), go to FF browser and paste the copied text in address bar. How should I do that without touching Mouse?

I am using Ubuntu OS and vim editor

Steps:

  • Open a file using vim
    vim temp.txt

  • copy a text line from temp.txt
    say the file has text www.google.com
    I'm using command v(for visual mode), shift+$ (to select the line) and y (to yank)

  • paste on Firefox browser address bar so that I can visit google.com

but not working (not able to paste).

Please help me with the command ?

Thank you

3

There are 3 answers

0
SBI On BEST ANSWER

Turning my comment into an answer:

"+ is the register that refers to the system clip board, this works for Linux as well as Windows (this is what I was able to test). You can copy to it with the "+y key strokes, given that you've previously selected something. To copy the whole line you're on, you can use "+yy (used as an example, you might have to google other cordes). You can then switch to firefox, with alt + tab for example, and then select the address bar using Ctrl+L, and paste using your system's paste shortcut, most likely Ctrl+V.

0
Ben Klein On

You can use the "* register to do this. For example, to yank a visual selection into the clipboard:

v2j " select two lines
"*y " yank into * register

You can use something similar with d to “cut” a selection or line; for example, to “cut” a line and have it available in the clipboard:

"*dd " delete current line and paste into clipboard
0
Ingo Karkat On

To open URLs directly from Vim (with your default browser), there are plugins that provide convenient mappings for that. I can recommend the open-browser.vim - Open URI with your favorite browser plugin for that.

This is more efficient than copy-and-pasting from Vim into your browser (and it doesn't clobber the clipboard contents, neither).