Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Does anyone have an elegant solution for having MacVim or gvim span across multiple(potentially different resolution) monitors? Having 2 sessions doesn't work well due to separate buffers and swap files.

You would think you could have 2 gui windows share the same buffers, but I can't find anything that works.

share|improve this question

migrated from stackoverflow.com Oct 26 '11 at 3:43

This question came from our site for professional and enthusiast programmers.

1  
I'd like to know the answer for this as well. I found this vimdoc.sourceforge.net/htmldoc/remote.html which seems like the right direction. But I haven't tried it out yet. –  Amjith Oct 25 '11 at 15:47
add comment

2 Answers

Expand the gvim window to cover both screens and use CTRL-W v to split the editing window vertically.

See :help CTRL-W for more window commands.

share|improve this answer
    
I'm well aware of splitting windows. This does not work well with different monitor resolutions unfortunately. Seems like there really isn't a good way to do this. –  Patm Oct 26 '11 at 16:10
add comment

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:

  1. find all instances of gvim which have "a.txt" open. (In this case, GVIM1)
  2. set all those a.txt buffers "readonly", "nomodifiable" and "autoread".
  3. The buffer which was modified will be written to the disk before set "readonly".)
  4. remove the swap file.
  5. 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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.