There is no simple way to do what you have described. You may be able to get some ideas from this CP article:
Syntax highlighting textbox written in C#[
^]
While this article is for syntax highlighting, the concept isn't too much different from what you have described. Essentially, you need to tokenize the text and perform some action on it based on the text. In this articles case, the action is to highlight or not highlight, and in your case your action is to edit or not edit. (You may even be able to use the synatx highlighting idea to identify those areas that can be edited)
If you get this working, I think it would make a great article!