6

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?

2

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.

| improve this answer | |
New contributor
Marco Crivaro Nicolini is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
  • 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 May 23 at 17:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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