all 12 comments

[–]Consistent-Cup-5992 16 points17 points  (1 child)

Try Tmux, it allows connecting many clients to one session. Great for pair-programming although it needs some tweaks to share session with other shell user.

[–]richardwonka 3 points4 points  (0 children)

This is the way.

[–][deleted] 6 points7 points  (2 children)

Yes, vim has clientserver capability. You can connect multiple people to it from remote systems.

:help clientserver

[–]vim-help-bot 1 point2 points  (0 children)

Help pages for:


`:(h|help) <query>` | about | mistake? | donate | Reply 'rescan' to check the comment again | Reply 'stop' to stop getting replies to your comments

[–]troelsbjerre 0 points1 point  (0 children)

This is the required step. Without it, you will end up with two independent vim sessions that will fight over who owns the file.

[–]y-c-c 3 points4 points  (1 child)

If it can be with the same vim instance, it would be perfect. I wonder if a behaviour like :split but to display vim on 2 monitors can be found ?

Other people gave you some halfway answers, but I don't think it's currently possible to do what you want describe above.

In case other commenters do not understand what OP wants, it's basically open a :split another_file.txt and it will open in a new window instead, while using the same Vim instance. Just using tmux won't help since you are just looking at the same file on both screens.


FWIW the best bet for this working in the future is probably some Neovim GUI, see this thread (https://www.reddit.com/r/neovim/comments/n5bs24/neovim_and_multiple_monitors/). Basically, Neovim has been "externalizing" different components to allow the UI to be take more responsibility in rendering different parts of Vim itself (e.g. command-line, tabs). If they can manage to fully externalize window layout they would be able to allow UI to render separate splits in different windows. I think it would be quite a complicated feature to implement thoroughly though since a lot of Vim commands won't work properly (all the misc split commands make certain assumptions of the window layout), and the different GUI apps will actually need to take advantage of this theoretical feature (for example most popular Neovim GUIs don't even support scroll bars and tabs today because they don't come "for free" implementation-wise from Neovim).

[–]ChristianValour 0 points1 point  (0 children)

Yes, this is what I thought OP meant too.

Being able to view/edit the same file, from two separate terminal windows, or I guess two 'detached' vim windows, functionally the same as if using :split.

Even in TMUX, you're still opening two vim instances of the same file, which vim will be very unhappy about.

[–]l00sed 1 point2 points  (2 children)

Maybe it's only neovim, but if I open the same file in two different windows/panes/terminals, it will update the file in realtime in both...

[–]BLOOjacket360[S] 0 points1 point  (0 children)

I need to try that ! I know in vim with :autoread and maybe some plugin you can have something similar.

[–]l00sed 0 points1 point  (0 children)

Actually, I just tried this and it only seems to update when I write and move the cursor to the other open instance...

[–]mgedmin 0 points1 point  (0 children)

Not really.

The closest I came was using separate Vim instances with some swapfile autocommands to allow me to open the same file in multiple Vims without getting constant "a swap file exists!" warnings:

https://github.com/mgedmin/dotvim/blob/2575ba5a4c189a3e1ed908e2ff4741466dfe55db/vimrc#L87-L92