LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   How do I paste into Vim (https://www.linuxquestions.org/questions/linux-software-2/how-do-i-paste-into-vim-768468/)

blastradius 11-11-2009 01:02 PM

How do I paste into Vim
 
Just getting used to Vim (please don't start the Vim vs Emacs thing, I've tried both and made my choice :-) )

How do I paste into Vim if I've copied from elsewhere? this only came to light when I wanted to paste some source code from Firefox into Vim and I just can't do it.

Is there something that I am missing or isn't it possible.

Thanks

Eric

anomie 11-11-2009 01:09 PM

It likely depends on the virtual terminal app you're using.

For example: I believe a default gnome-terminal configuration will paste with the Ctrl+Shift+V key combo. (Don't forget to enter editing mode and position your cursor in vim first...)

pixellany 11-11-2009 01:12 PM

Always try right-clicking. I have discovered all manner of things by doing this. In Konsole, eg, there is copy and paste, plus several other things including the configuration menu.

sycamorex 11-11-2009 01:15 PM

In konsole 'paste' is assigned the following keys Shiff+Ctrl+insert

blastradius 11-11-2009 01:37 PM

Thanks for the quick replies.

ctrl + shift + v pastes into the terminal but chops off the first letter which is odd. I can paste into GVim selecting from the menu but what on earth does the keybinding "+gP mean!

markush 11-11-2009 03:13 PM

Hi blastradius,

before pasting with shift+ctrl+v you'll have to enter the insert-mode in vim (press for example the i- or a-character). Otherwise the text will be inserted beginning with the first character which enters the insert mode.

Markus

wit_273 11-11-2009 04:35 PM

To copy/cut paste in vim you user delete, yank, and paste. The vim wiki has instructions for doing this at http://vim.wikia.com/wiki/Copy,_cut_and_paste. The Ctrl functions used in many text editors will not always work in vi(m). But delete, yank, and paste will always work--so this is the best way to learn (and get in the habit) of doing when in vi(m).

manwithaplan 11-11-2009 05:34 PM

I can't stand Vim ... completely crazy idea for an editor .. IMHO Sry, just needed to rant.

chrism01 11-11-2009 07:21 PM

You can't use the yank etc cmds if you're copying from an external src as per OP.

In FF, use highlight+Ctrl-C to copy, the move mouse to vim editor, press 'i' to go into insert mode (or <esc>i to make sure you are in right mode), then right-click to paste.
If right-click has issues, try the paste option from whatever terminal menu is avail

karlochacon 11-11-2009 09:17 PM

why nobody likes nano? :scratch:

pixellany 11-11-2009 09:58 PM

I love nano---and my name is not "nobody"........;)

jtshaw 11-11-2009 10:15 PM

Also... if you are pasting into Vim from an outside source you might get odd tabbing behavior. To fix this turn on paste mode (set paste / set nopaste).

Quote:

Originally Posted by karlochacon (Post 3753686)
why nobody likes nano? :scratch:

While I'm sure somebody likes nano, I don't like text editors that can mangle your file with their default wrap behavior...

blastradius 11-12-2009 01:23 AM

Thank you everybody, my question is now fully answered.

For the record one of the reasons I've chosen Vim is the community out there, I posted a question at 7:02pm, got my first response at 7:09 and have just read replies which came in overnight (in the UK that is). This many people using a piece of software can't be wrong! I found I was distracted with other software (too many bells and whistles and things to fiddle with), Vim edits and it does it extremely well.

Thanks again. God knows why I didn't pick up on not being in insert mode when pasting in the terminal (probably because I had no problem pasting into Gvim), thanks to Markush for that one.

chrism01 11-12-2009 06:48 PM

If you work in the *nix world, the one editor you can guarantee to be avail on HP-UX, Solaris, Linux (any), *BSD is vi ... and vim is just Vi Improved :)
Most commercial servers don't have a GUI either, so you need to know a cli editor ie vi .


All times are GMT -5. The time now is 04:31 AM.