Recently I have been having some issues with hooking an external monitor up to my Macbook (worked at first, now will detect but wont display anything). I found that the solution may be to delete com.apple.windowserver.plist in the Preferences directory and let OS X restore it for me on reboot. However, when looking through that directory I have found that the file doesn't even exist there anymore! Is there any way I can run a repair on my filesystem to restore that file or will I have to re-install OS X (FYI I'm running latest Snow Leopard)?
Files in the Preferences directory can be safely deleted.
Apps automatically create these files if they don't exist already and fill them with default values.
This is how apps can be installed simply by dragging the .app into the applications folder.
Next time that file is required, it will be created and populated with default values.
I just tested on my system: I deleted /Library/Preferences/com.apple.windowserver.plist. I logged out and back in, and that didn't restore the file. But, I tried rearranging my monitors in System Preferences-> Displays-> Arrangement, and the file was neatly recreated.
So, short answer: That file will be automatically recreated as soon as it's required. Don't sweat it.
The same applies to just about every, if not every, .plist preferences file.