On Windows, a new line is
\r\n
-
CRLF
but on Unix based systems, a newline is
\n
-
LF
. That could be one of the things you needed to replace.
Windows keeps the newline format of the platform your program is running in at
System.Environment.NewLine
And if you don't mind using Regex. You could remove multiple lines in a single pass on both platforms like this
string formatted = Regex.Replace(rtxtTypeing.Text, @"(?:\r\n|\r(?!\n)|(?!<\r)\n){2,}", System.Environment.NewLine);
See
Replace multiple line breaks with a single br[
^]
Replace line breaks in a string[
^]