Imagine programming something in Java or C++. You have a file, which is about 5000 lines worth of pure code. Every time you type a single letter, and pause for a split second (think Eclipse or Visual C++), the IDE will show a bunch of errors throughout your file (or maybe only the same line, depending on the editor). What I'm wondering is, how does an IDE do this? I can only imagine that an IDE which reads the entire text file every single time you type a letter, would be majorly inefficient and would probably start slowing down real fast when someone hits a certain quantity of characters.
I'm not looking for a complete algorithmic solution or something like that. I'm looking to write a very simple editor for fun, and I'm wondering how I should incorporate the whole scanning of a file thing. Even if I want to have a different color for a keyword (this, class, static, extern, transient, public, private, protected, etc), I'd have to be able to know how I should implement this scanning "algorithm".