I once used something called Floobits[1] that was capable of this. In practice collaborative editing wasn't that much more useful vs screen sharing and the additional constraints of managing Floobits workspaces didn't make it worth it for us.
I did pair programming on XEmacs in the 90's by opening a new frame on a second X server. It worked surprisingly well as long as both people stayed out of the minibuffer.
That looks nice, however for those interested, only the plugins are opensource and usage is not free. The good thing is that it shows what is possible.
i find collaborative editing most useful for online docs, like wiki pages, etc. not having to worry about locking makes a big difference when editing is fast paced
[1] https://floobits.com/