Question

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

Is it possible?

Was it helpful?

Solution

Copy whatever you like, in Vim, press Shift+Insert to paste content in clipboard into file. Make sure you are in Insert Mode. It works well in Ubuntu 12.10 as long as I tried.

EDIT Before the paste, it is recommended to enter the paste mode (by :set paste) of vim in case you meet some un-wanted feature like incorrect auto-indent. (Thanks to @DmitryFrank)

OTHER TIPS

I assume you are running windows and using gvim. To copy from Notepad, just select the text and use the normal Ctrl-C. To paste in vim, specify the clipboard register in normal mode and use the normal p command like this "+p.

Similarly, you can go the other way with "+yy to grab a line from vim.

If you are in Ubuntu or some other Linux, the above trick should still work, but you need to make sure you have the full version of vim with clipboard enabled. In Ubuntu, try running sudo apt-get install vim-gtk.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top