1

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.

Rituraj ratan
  • 10,260
  • 8
  • 34
  • 55

3 Answers3

3

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

aelor
  • 10,892
  • 3
  • 32
  • 48
2

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

Justice Fist
  • 111
  • 4
2

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

Justice Fist
  • 111
  • 4