Cutting and pasting between two different files

170 views
Skip to first unread message

Dave

unread,
Oct 18, 2012, 2:18:13 PM10/18/12
to vim...@googlegroups.com
Hi,

I'm using vim 7.3 on Mac 10.7.5. How do I enable cutting and pasting between different vim sessions within the same shell? That is, I start one vim session, copy some text, quit the file I'm editing, open a new file, and then paste what I copied in the previous file. I have seen this on other versions of vim I've used (don't remember the version numbers), and so wanted to ask how this can be configured, if at all.

Thanks, - Dave

Michael Hernandez

unread,
Oct 18, 2012, 3:20:19 PM10/18/12
to vim...@googlegroups.com
> --
>
There's no need to quit the file you're editing in order to open a new file. Just use :edit or something similar to open a new file in another buffer or tab and paste at will.

--Mike H

Tony Mechelynck

unread,
Oct 18, 2012, 4:08:04 PM10/18/12
to vim_mac
As Michael said, you don't need to quit the first file. You can open
the second file in a split-window or in a new tabpage in the same Vim.

If the file where you want to paste is already open in a different
Vim, you should be able to paste via the clipboard (provided of course
that both Vim instances were compiled with +clipboard and have access
to the clipboard). This works on Windows and on Linux, I haven't tried
it on a Mac.

Best regards,
Tony.
--
Manual, n.:
A unit of documentation. There are always three or more on a
given item. One is on the shelf; someone has the others. The
information you need in in the others.
-- Ray Simard

David Sanson

unread,
Oct 18, 2012, 10:17:00 PM10/18/12
to vim...@googlegroups.com
By default, yanking doesn't yank to the system clipboard, and so the yanked text isn't available across different instances of vim. You can use "*y to yank text to the system clipboard and "*p to put text from the system clipbooard. Or you can put `set clipboard=unnamed` in your .vimrc, to use the system clipboard as the default register.

(I'm no expert, so someone please correct this if it is wrong or misleading.)

Dave

unread,
Oct 18, 2012, 11:19:37 PM10/18/12
to vim...@googlegroups.com
On Thursday, October 18, 2012 9:17:00 PM UTC-5, David Sanson wrote:
> By default, yanking doesn't yank to the system clipboard, and so the yanked text isn't available across different instances of vim. You can use "*y to yank text to the system clipboard and "*p to put text from the system clipbooard. Or you can put `set clipboard=unnamed` in your .vimrc, to use the system clipboard as the default register.
>
> (I'm no expert, so someone please correct this if it is wrong or misleading.)

Hi, I created a file ~/.vimrc with

set clipboard=unnamed

but sadly no dice, yanking and pasting between two files. Thanks for the suggestion though, - Dave

Tony Mechelynck

unread,
Oct 19, 2012, 3:37:48 PM10/19/12
to vim_mac
On Oct 19, 4:17 am, David Sanson <dsan...@gmail.com> wrote:
> By default, yanking doesn't yank to the system clipboard, and so the yanked text isn't available across different instances of vim. You can use "*y to yank text to the system clipboard and "*p to put text from the system clipbooard. Or you can put `set clipboard=unnamed` in your .vimrc, to use the system clipboard as the default register.
>
> (I'm no expert, so someone please correct this if it is wrong or misleading.)

On Windows, the * (star) and + (plus) registers both mean the system
clipboard.

On X11 systems, the + (plus) register is used by most programs
(including gvim) for Edit→Copy, Edit→Cut and Edit→Paste, while the *
(star) register is filled in most programs by selecting (highlighting)
something on the screen, and pasted by clicking the middle mouse
button.

I'm not sure what happens in MacVim but you might try, at first, to
start Visual mode (selecting whatever you want to copy) then use
Edit→Copy in one instance and Edit→Paste in the other. If it works,
look on the right side of the Edit menu which commands are triggered
by these menuitems. Here on Linux, Edit→Copy means "+y and Edit→Paste
means "+gP (the difference between P and gP is that gP leaves the
cursor after the pasted text).

David Sanson

unread,
Oct 19, 2012, 9:08:59 PM10/19/12
to vim...@googlegroups.com
Are you using the system vim on 10.7, or macvim? The system vim might not be compiled with clipboard support. Try

vim --version

And look for a +clipboard in the features list.

Reply all
Reply to author
Forward
0 new messages