Take a look at how Smalltalk does this (try Pharo, for example). You don't edit code as a whole: you add classes, methods, fields and edit them separately.
This has several benefits: changes are isolated - easier to reason about and track in version control system, refactoring is easier.