2

Always, I am using vim as my text editor. But, when I want to copy full file's content in clipboard to paste another place I open the file in gedit and press CtrlA and then CtrlC.

Opening the file in text editor and pressing CtrlA and then CtrlC is overhead to me. Because I have to open the file in text editor, although I don't edit the file.

So, if there is any command that can copy the file's content in clipboard it better.
e.g.
clip file.txt

There also a possibility to gain this feature in vim by mapping CtrlA to some command or make a clip command to copy. But, I don't know how to copy entire file in vim using command.

N.B. My vim doesn't support +clipboard.

alhelal
  • 1,301

2 Answers2

4

xclip will do what you want

xclip -selection clipboard -i <file>

note that -selection clipboard is only needed if you want the file in the clipboard (thats the CtrlC and CtrlV one) if you omit it the files content will be put into the primary buffer (thats the one where you paste by clicking the mousewheel).

alhelal
  • 1,301
Captain Wobbles
  • 366
  • 1
  • 5
1

A few things you could try here.

1) From vim type in gg"+yG from normal mode, this will bring you to the top of the file, then paste all lines onto the clipboard.

2) You could try catting the file, highlighting it, then using ctrl-insert to copy the highlighted text.

3) As above, but right click on the top bar of the window and look for and Edit/Copy option.

Cheers, Paul T

Paul T
  • 301