Okay, so I was having exactly the same problem, which is what brought me to this question. I have a split session, vim code on the left and a scheme prompt on the right.
My problem was, I thought the session name was the socket name, but they are two different things. I had named the session '0', for the 0-th window, but in fact, the SOCKET is named 'default' despite the session name I specified.
To get a list of the tmux sockets run:
lsof -U | grep "^tmux"
I found that from this answer:
https://stackoverflow.com/questions/11333291/is-it-possible-to-find-tmux-sockets-currently-in-use
The above was helpful to see the actual names of the sockets.
That is what you put in the first prompt. I was putting '0', which was the name of my session, but it was not working. 'default' is what is needed there despite the fact I had named the session.
Then, at the second prompt, I entered (index-0 window, index-1 pane):
:0.1
Voila! Finally! It was working. Brilliant, now side-by-side
editing!
Well after going through a LOT of web pages, many giving some hints that did not seem to work, I found a hint (extra text around a paste) that lead me to the cause and the solution to the problem.
It seems that vim has built into it a number of 'fake' termcap entries which it uses when it recognises specific terminals (and sometimes gets wrong, though it wasn't wrong in this case).
Termcap settings in vim are numerious add as such DOES NOT show up in a normal ":set all" setting list. To see them you need to use ":set termcap". The specific 'non-standard' termcap setting is "t_BE" (see vim ":help t_BE"). The built-in help "xterm-bracketed-paste" explains this internal-to-vim termcap setting.
Basically if this setting is defined (in this case by Vim not termcap/terminfo) then vim will send it to the xterm when it starts up, which tells xterm to add special codes around any text the user pastes from an external source. When vim sees these it automatically goes not only into insert-mode but also sets 'paste-mode' so as not to format the text.
The later (paste-mode) is I think VERY useful! The former is what has been giving me all the trouble.
The brute force solution is disable bracketed-paste by adding this to the ".vimrc"
:set t_BE=
An Alternative Solution....
Instead of disabling bracketed-paste completely, stop vim taking action when it sees the starting sequence of a terminal paste (from the mouse), while in command or normal-mode.
:nmap <PasteStart> <NOP>
:nmap <PasteEnd> <NOP>
:cmap <PasteStart> <NOP>
:cmap <PasteEnd> <NOP>
Using this means that if you do paste text while in insert-mode vim will not try to format (indent) text that is more than likely already indented.
This does not mean I no longer need to toggle paste-mode, as I also use the paste-mode toggle (mapped to F2) to disable "showbreak" and "listchars" (displaying wrapped lines, tabs, no-break spaces, and extra spaces at the end of lines). I would still need to put vim in that mode when I want to make mouse selections to paste elsewhere.
Comments and Suggestions on the solutions are welcome.
Best Answer
You can execute shell commands in vim using the command:
:!foo -fooparam
You can insert the output of shell commands similarly using:
:r!foo -fooparam