How does Visual Studio handle line terminators internally?
The Visual Studio editor allows all types of end of line markers to be used by files. Actually, each line in the file may use a different line terminator. You can get the info on which marker is used for a line with the IVsTextLines::GetLineData() function. It fills a LINEDATA structure which contains an iEolType member: eolCRLF, eolCR and eolLF are of course the regular terminators.
How can you know what type of terminator to insert if you perform some manipulation yourself? What I do is, when I want to insert a terminator in line N (actually, splitting line N in two), I insert the same type of terminator there already is in that line. In this way, it works with the most common regular files and it would still do something sensible in mixed-EOL-markers files.
Note that, even if the text editor deals correctly with these mixed files, you shouldn't use them. Not only because of the "ugliness", but because the compilers in the environment (at least the C/C++ compiler) don't understand them correctly. If there is a line terminated with just LF in a file full of CR-LF's, the preprocessor won't increment the internal line number when going past that line, and all subsequent warnings/errors will be reported with an off-by-one line number! I can tell you it drove me nuts until I found out what was happenning :)