I also often use multi-monitors, so I made a simple workaround to use until vim implements this feature.
Using a lua script named gitv, I can open a file on multiple instances of GVIM at the same time.
Basically, when there are two instances of GVIM named GVIM1 and GVIM2,
what I did was simply to make sure that only one file is editable at one time, and all the others are viewers. (Everything is done automatically without prompting.)
Workflow:
Currently, gitv is designed for git repositories, so it can be used only for those files in a git repository. You can easily change this default behavior by modifying lsFiles() function.
To first open a.txt on GVIM1, use
$ gitv gvimr GVIM1 a.txt
This will open a gvim window if there isn't one.
Then to open the same a.txt on another instance GVIM2, use
$ gitv gvimr GVIM2 a.txt
(or you can make an alias like $ gvim2 a.txt)
Then gitv internally does the followings:
- find all instances of gvim which have "a.txt" open. (In this case, GVIM1)
- set all those a.txt buffers "readonly", "nomodifiable" and "autoread".
- The buffer which was modified will be written to the disk before set "readonly".)
- remove the swap file.
- re-open a.txt on GVIM2. (gvim can open that file without problem because there is no swap file.)
If you want to edit a.txt on monitor 1 instead of monitor 2, do this to switch the active buffer:
$ gitv gvimr GVIM1 a.txt
(or gvim1 a.txt)
This can be done more easily inside gvim1 using ctrl+g + a.txt
(This will automatically set the same buffer open in other instances of gvim "readonly"
to prevent data corruption.)
gitv can be downloaded here: http://code.google.com/p/gitv/
It was tested only on linux gvim, but it could easily be ported to MacVIM.
1
I'd like to know the answer for this as well. I found this http://vimdoc.sourceforge.net/htmldoc/remote.html which seems like the right direction. But I haven't tried it out yet.
– Amjith – 2011-10-25T15:47:13.257