10

I work with two displays.

I usually open one instance of Vim in display #1 (let's call it Vim #1), which over time ends up having an open buffer for nearly every file in a project.

Now I want to open one of the files in display #2, with a separate instance of Vim (#2). I ideally want to see the file in the same state I've got it somewhere inside Vim #1: with the same unsaved changes.

I ultimately want to have two separate Vim instances simultaneously editing one buffer (possibly sharing the same .swp?).

Is there a way to do that in Vim?

8
  • 1
    Perhaps the CoVim plugin works for you. Commented Oct 24, 2017 at 11:31
  • If you open a vertical split window with ctrl-w + v you'll have 2 instances. It doesnt allow for you to split over 2 physical screens if thats what you wanted, unless you make it really big so it flows over the two displays haha
    – ljden
    Commented Oct 24, 2017 at 14:13
  • never actially tried that, but wouldn't vimdoc.sourceforge.net/htmldoc/remote.html solve your problem?
    – B.G.
    Commented Oct 24, 2017 at 14:15
  • possible cross-site duplicate question on SO: stackoverflow.com/q/15444823/4748017
    – Herb
    Commented Oct 24, 2017 at 16:04
  • 1
    @HerbWolfe That question is about sharing registers. This one is actually about buffers. Commented Oct 25, 2017 at 8:12

2 Answers 2

3

If you are still looking for an answer and willing to try neovim, the neovim-remote does what you need. From the readme:

Open files always in the same nvim process no matter which terminal you're in.

If you just run nvr -s, a new nvim process will start and set its address to /tmp/nvimsocket automatically. Now, no matter in which terminal you are, nvr file will always work on that nvim process.

1
  • 2
    This is not really for opening the same file in two (Neo)Vim's, but instead to open a file in an existing instance of NeoVim. For example, if you use nvr as your $EDITOR, then when you git commit, instead of opening a new NeoVim to type the commit message, it will ask the already running NeoVim (which might be in a GUI window) to open that file to edit it. Once you save&close the file there, nvr will say it's done, so git commit will continue. That's something original Vim has supported as --remote but NeoVim didn't have it natively...
    – filbranden
    Commented May 23, 2020 at 17:37
1

I have been looking for a solution to this problem for quite a while now and just found out (pretty much by accident) that there is a GUI wrapper for Neovim, which has support for independent windows for the same instance!

https://github.com/yatli/fvim

You can detach a window into an external OS window with Ctrl+w g e.

Unfortunately I have discovered that it doesn't really play well with some plugins, so I don't use it at the moment. It might be worth keeping an eye on the following list to see if any of the other GUI wrappers implement a similar feature: https://github.com/topics/neovim-guis


Edit: I have just found some more approaches towards a solution to the same problem:

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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