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.
-
what OS are you running? and are you talking about the GUI gedit? – Andrew Brown Mar 20 '14 at 05:09
-
i am using ubantu 12.10 – Rituraj ratan Mar 20 '14 at 05:09
-
i'm assuming that's some linux variant? did u mean ubuntu? if you're not just in a console and trying to copy to the GUI gedit, highlighting the text, and middle clicking in gedit will work. – Andrew Brown Mar 20 '14 at 05:11
-
This question can be useful to you as well : http://stackoverflow.com/questions/3961859/how-to-copy-to-clipboard-using-vim – ElefEnt Mar 20 '14 at 10:09
3 Answers
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

- 10,892
- 3
- 32
- 48
highlight the text in vim with the mouse, then use the middle click button on your mouse in gedit

- 111
- 4
-
it works for me but i am interested with command now i am checking your second answer – Rituraj ratan Mar 20 '14 at 05:15
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

- 111
- 4
-
-
great it works for me can you explain your answer in step by step – Rituraj ratan Mar 20 '14 at 05:29