_       _       
  (_) ___ | |_ ____
  | |/ _ \| __|_  /
  | | (_) | |_ / / 
 _/ |\___/ \__/___|

Pair programming using tmux and Vim

On the host system, create two users ("alice" and "bob" in this case) and a group that both users are members of ("programmers" in this case):

sudo su
adduser alice
adduser bob
groupadd programmers
usermod -a -G programmers alice
usermod -a -G programmers bob

As Alice, start a new tmux session ("sharedsesh") connected to a socket on "/tmp/sharedsesh", change the group of the socket to "programmers" so that both users can access it, and tell tmux to allow bob access.

tmux -S /tmp/sharedsesh new -s sharedsesh
chgrp programmers /tmp/sharedsesh
tmux server-access -a bob

As Bob, connect to the shared tmux session:

tmux -S /tmp/sharedsesh attach -t sharedsesh

Finally, run Vim (and/or whatever you like in the shared tmux session) to do your pair programming. In the following screenshot, I've used su to become alice in one terminal and bob in the other before connecting both to a shared tmux session and editing/compiling a C program in Vim.

Screenshot of alice's and bob's respective terminals connected to a shared tmux session

For one user to detach from the tmux session without closing it, they press the tmux leader key, "^b", followed by "d".

Further reading