Rituraj ratan
Rituraj ratan

Reputation: 10378

How to copy paste from vim to gedit?

I am new in vim and i want to copy text from vim and paste in gedit. In vim I know copy paste by command mode and visual mode but from vim to gedit I have no idea.

Upvotes: 1

Views: 4252

Answers (3)

aelor
aelor

Reputation: 11116

you cannot access the clipboard from vim unless you have a +xterm_clipboard

run this command

vim --version | grep "xterm_clipboard"

if you get +xterm_clipboard then its okay but if you get -xterm_clipboard then you need to compile your vim with xterm_clipboard enabled.

Furthermore, you can install the vim-gnome

sudo apt-get install vim-gnome

and after that when you check the

vim --version | grep "xterm_clipboard" 

you will get a +xterm_clipboard

open your file in vim

$ vim text.txt

type the following keys in this order

gg"+yG

this will copy the whole text into the system clipboard, then you can directly copy it into any other thing (gedit, browser etc) using Ctrl+v make sure to keep the file open in vim or else closing the vim editor will clear the contents of the keyboard.

another option can be using

gg"*yG

which copies the text to the external tools using middle mouse click

Upvotes: 3

Justice Fist
Justice Fist

Reputation: 111

find the file on disk. using the console, type

cat thefile | xsel -b

paste (ctrl-v) in gedit

You might have to first sudo apt-get install xsel

Upvotes: 2

Justice Fist
Justice Fist

Reputation: 111

highlight the text in vim with the mouse, then use the middle click button on your mouse in gedit

Upvotes: 2

Related Questions