In screen, would it possible to open up all instances of vim in one window? (e.g. window 2) Initially, the window will switch to the designated window and open up the file in the buffer. And consequent invocation of vim (from other windows) will open the file in new tab of vim in that window. I am running cygwin.
This is a great question and an awesome idea! I can't wait to incorporate it into my workflow.
Anyway, in my opinion, the best way to pull this off is to use vim's server functionality, which allows you to control your running vim instance using the vim command.
The idea is that the first time you run vim, you'll run it as:
and then everytime you want to open a new tab in this instance, you'll run:
Apart from this, the only thing you'll need to add is the logic for identifying and switching to the vim window (which can be done using the window title).
I've put all of this together in the following shell function:
If you add this function definition in
Notice that I also reset the window title to the shell name if/when you exit the vim server, this is to avoid having two or more windows with the title "vim" if you use
Because I'm more of a tmux guy, this is the shell function I'm actually planning to use:
This version of the function will work for both tmux and screen (as many different sessions as you like), and fallback to normal vim if not within either.
You can't run two instances of vim in different screen windows that will allow you to edit one file simultaneously from both instances. If you try to open a second instance of vim to edit the same file, you will get a message warning you that the file is already being edited.
That said, you can open a second instance of vim in a new screen window to view the current file by executing this command within vim: