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

StackOverflow https://stackoverflow.com/questions/20637129

  •  18-09-2022
  •  | 
  •  

Question

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

Was it helpful?

Solution

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.

OTHER TIPS

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

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).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top