10

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.

1

2 Answers 2

1

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.

1
  • 1
    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, 2011 at 16:10
1

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .