4

I'm trying out vim after being a long term user of textmate, and while I can see the appeal of the app, even something as simple as selecting all on vim called on the a command line to paste into another app seems needlessly complex.

How do you make whatever you yank into the buffer available to other apps?

At present, I'm typing ggvG to select the whole file, and then typing y to yank it into the buffer, but this buffer isn't available to other apps.

I'm using Ubuntu Jaunty (the stock netbook remix install) and I'm using vim 7.2.79.

Also, is there a way to get a simple gui wrapper vim this as well, like how you have with macvim?

2
  • Ah, thanks CMS. This seems to have resolved it, though I'm still somewhat puzzled as to why this should take 3 keystrokes. Is there a good reason people don't bind this to crtl+c for adding to the universal clipboard like the rest of the planet? Jul 15, 2009 at 10:07
  • 1
    Probably because Ctrl-C is more traditionally the keystroke for sending SIGINT to a running process, and Vim was a console app before it was a GUI app, so Vim uses Ctrl-C as an interrupt command also. You can easily rebind it yourself. vmap <C-c> "+y or something similar. But read :h map_CTRL-c first. Jul 15, 2009 at 17:52

5 Answers 5

9

There are lots of options for this:

Copy to the middle click register (selection clipboard):

gg"*yG

Copy to the copy-and-paste clipboard

gg"+yG

These both work by using gg to go to the start of the file, "+ or "* select the register, y starts the yank and G is a motion to the end of the file.

To use the visual approach, you would do ggvG"+y (or replace + with * for the selection register).

Use command mode to do the same:

:%yank "
" Or:
:%yank +

For more information, see:

:help :yank
:help quoteplus

To use the * register by default, you can do:

:set clipboard=unnamed

This allows you to use ggyG or :%yank (without a register specifier) and then middle click to paste.

:help 'clipboard'
1
  • 2
    and if this is too much to type, then define some mappings for the relevant commands in your .vimrc
    – Blixtor
    Jul 15, 2009 at 12:55
4

Copy your text to the * register:

  gg"*yG

Then middle-click on any application to paste it..

2
  • 3
    This requires +xterm_clipboard - see :version - which I think is only available in "big Vim" on Ubuntu. The default Vim is the minimal version that had lots of features disabled at compile time!
    – richq
    Jul 15, 2009 at 7:42
  • Installing the vim-gtk package got this working for me in Ubuntu.
    – Steve
    Nov 2, 2012 at 14:30
2

Why not "select with mouse" - "paste with middle button" pattern?

0
1

Oh dear, hanging my head in shame.

Just discovered gvim in accessories on ubuntu.

1
  • Oh hang on, this still doesn't solve the pasting problem - I'm still unable to paste from vim to other apps. Is this standard behaviour? Jul 15, 2009 at 7:46
1

I do it like this:

  • in vim: gg SHIFT+v G "+y
  • in other app: middle button or ctrl+v

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.