Vim uses the system cut-and-paste mechanism to copy text between instances. When you run vim in a terminal, it doesn't have direct access to any cut-and-paste mechanism. If vim is running in xterm or some other terminal that provides access to X selections and clipboard contents, vim can use that; however your vim binary is compiled without support for that feature.
If both vim instances are running on the same machine, you can use a temporary file to communicate:
:w ~/vim.tmp
:r ~/vim.tmp
If both vim instances are connected to the same X display (in that the DISPLAY
environment variable points to the same X display, the vim programs themselves don't need to have any kind of X support), you can use the X selections via an external program such as xsel or xclip. You can omit the p
or -selection primary
or choose a different selection (-s
/secondary
or -b
/clipboard
). Use :w !
(note the space) to copy:
:w !xsel -ip
:w !xclip -i -selection primary
and :r!
to paste:
:r !xsel -op
:r !xclip -o -selection primary
This question is a bit old, but I was looking for something similar, and found it here. It creates a second session that shares windows with the first, but has its own view and cursor.
tmux new-session -s alice
tmux new-session -t alice -s bob
If the sharing is happening between two user accounts, you may still have to mess with permissions (which it sounds like you had working already).
Edit: As suggested, a quote from another answer:
First, add a group for tmux users
export TMUX_GROUP=tmux
addgroup $TMUX_GROUP
Create a directory with the group set to $TMUX_GROUP and use the setgid bit so that files created within the directory automatically have the group set to $TMUX_GROUP.
mkdir /var/tmux
chgrp $TMUX_GROUP /var/tmux
chmod g+ws /var/tmux
Next make sure the users that want to share the session are members of $TMUX_GROUP
usermod -aG $TMUX_GROUP user1
usermod -aG $TMUX_GROUP user2
Best Answer
You'll have to use tmux shortcuts. Assuming your tmux command shortcut is the default: Ctrl+b, then:
Ctrl+b, [ Enter copy(?) mode.
Move to start/end of text to highlight.
Ctrlspace
Start highlighting text (on Arch Linux). When I've compiled tmux from source on OSX and other Linux's, just Space on its own usually works. Selected text changes the colours, so you'll know if the command worked.
Move to opposite end of text to copy.
Alt+w Copies selected text into tmux clipboard. (On Mac use Esc+w.)
Move cursor to opposite tmux pane, or completely different tmux window. Put the cursor where you want to paste the text you just copied.
Ctrl+b, ] Paste copied text from tmux clipboard.
tmux is quite good at mapping commands to custom keyboard shortcuts.
See Ctrl+b,? for the full list of set keyboard shortcuts.