0

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

RaviRokkam
  • 789
  • 9
  • 16
  • [Duplicate](http://stackoverflow.com/questions/11416253/how-to-map-yank-to-oss-clipboard-in-vim) – Nick Dec 17 '13 at 14:47
  • Well, what are you trying? Copy to the shared clipboard ("+y) and then change to firefox, select address bar with Ctrl+L and paste with Ctrl+V. – SBI Dec 17 '13 at 14:48
  • @SBI why not put that in answer? – Kent Dec 17 '13 at 14:49
  • Vim is multi-platform; at least tell us the operating system you're using; the exact steps may depend on that. – Ingo Karkat Dec 17 '13 at 15:01
  • @Kent I didn't know if the problem wasn't with something else. I've added my answer now. – SBI Dec 17 '13 at 15:02

3 Answers3

2

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.

SBI
  • 2,322
  • 1
  • 17
  • 17
1

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
Ben Klein
  • 1,719
  • 3
  • 18
  • 41
1

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

Ingo Karkat
  • 167,457
  • 16
  • 250
  • 324