I'm thinking about creating a collaborative code editor, similar to Etherpad or Google Docs for documents. However, if such a thing exists, I don't intend to reinvent the wheel.
Cloud9 is a good web-based IDE for team-based development.
However, I think it's worth noting that working on the same file with multiple developers is just one workflow. The reason that Git is still the predominant workflow instead of collaborative IDEs is that there is a benefit in working on your own version of a file, and only merging when necessary.
Lorefnon
Open Web Enthusiast
The original Etherpad (currently unmaintained) is itself an open source java+javascript based application. The team is now working on a pure javascript solution etherpad-lite which is much more modular. The latter should suffice for your needs.
If you need something more custom, both codemirror code editor, and prosemirror (by the same author) have support for collaborative editing. You may also want to look at ot.js, which is a more generic and lower level library for operational transformation. OT is a well studied problem for which numerous approaches exist.
An alternative to operational transformation is diffing and patching, which may be better suited (eg. if your input control is a complex widget and user interactions don't map as is to state change of the widget) or more bandwidth efficient (though it is also possible to compress ot change sequences before transmitting). Google has published a very good open source library for this, which is available in several languages.