You're looking for a source control solution. These are a common part of the industry. Large Open Source projects often have dozens (and in a few cases hundreds or thousands) of individual developers spread over the entire world.
Solutions like GitHub, BitBucket, SourceForge, and more offer these services for free (often only if you make your code publicly viewable, though). They allow you to "commit" changes and "push" them to a central server, then allowing the other developer(s) to "pull" those changes.
This is not instant. You don't usually want it to be. You want to be able to compile and run your changes against a known stable/functional base and then only sync up when you have completed a feature or fix, thereby ensuring that you aren't held back by a teammates incomplete changes or vice versa.
If you both edit the same file, you will have to "merge" your changes when syncing. Modern tools usually do a fairly good job of figuring this out automatically, though something you'll have to help it out and manually figure out how to merge some overlapping changes. Typically, just avoid doing this; there is usually little reason for two developers to be simultaneously working on the same feature or fix, even if sitting next to each other, much less when geographically separated. Your project likely has a number of different tasks which can be completed in parallel.
This is how multi-developer projects are handled in the corporate world, the Open Source world, and even most smooth private/small/school/hobbyist projects.
An additional advantage to a good source control system is that it maintains history, allowing you to back up to an older version if necessary, see who made which change, and so on.
If you really want instantaneous syncing, you might consider using DropBox. Your IDE will typically have some trouble if edits are made to the file, but again, just don't do that.
There are also some text editors (generally not full IDEs) that have networked text editing, or even some online editors. The experience will not be a good one.