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.
3 Answers
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.
-
-
@In78 If you install
vim-gnome
, or one of thevim
packages like stated in my answer, then it works fine fromvim
,vi
, etc.– TerranceJun 25, 2015 at 6:11
Using a pastebin service
pastebinit -i <my_file> -b http://paste.ubuntu.com
You will see an URL. Open the URL in Chrome.
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...
- Starts a yank command to the register
G
- go the end of the file
Reference:
Shamelessly copied from: https://stackoverflow.com/questions/1620018/copy-all-the-lines-to-clipboard/1620029#1620029
-
1