9

I want to select all contents of a file and copy it to google chrome. I have tried shift-ctrl-c but it isn't working.

In78
  • 623

3 Answers3

11

From the beginning of the file, type in the key sequence to copy the entire contents to the clipboard:

:%y+

if you want to copy just one line, move the cursor to the start of the line you want, and type in the following key sequence:

:y+

or like stated in another answer here, copy the entire contents to the clipboard + instead of the * registers try:

gg"+yG

for these key sequences to work, you need to have gvim installed, or one similar to it, that will make it so vim has the ability to copy to the clipboard. Below are 3 packages that will enable the +clipboard for vim.

sudo apt-get install vim-gnome

or

sudo apt-get install vim-athena

or

sudo apt-get install vim-gtk

I personally prefer vim-gnome but any of them should work fine.

Terrance
  • 41,612
  • 7
  • 124
  • 183
  • I tried :%y+.. But it is giving an error E850: Invalid register name – In78 Jun 25 '15 at 06:06
  • @In78 If you install vim-gnome, or one of the vim packages like stated in my answer, then it works fine from vim, vi, etc. – Terrance Jun 25 '15 at 06:11
6

Using a pastebin service

pastebinit -i <my_file> -b http://paste.ubuntu.com

You will see an URL. Open the URL in Chrome.

A.B.
  • 90,397
5

Use the keystrokes below:

gg"*yG

to copy the text to the * or + registers: Explanation:

  • gg
    • gets the cursor to the first character of the file
  • "*y
    • Starts a yank command to the register * from the first line, until...
  • G
    • go the end of the file

Reference:

Shamelessly copied from: https://stackoverflow.com/questions/1620018/copy-all-the-lines-to-clipboard/1620029#1620029

Ron
  • 20,638