Sublime Forum

Regex: Carriage Return not found


There is a recurring need to find windows carriage return characters and the regex “\r” never matches a thing in my sublime text 2. Newline “\n” always works.
I have checked the binary codes with Total Commander and it shows 0D 0A patterns in text where line breaks show up in windows notepad. And sublime
finds the newlines as \n OR binary x0A. It never finds any of the carriage returns as \r OR as the binary equivalent 0D, even though they are there for certain.

I have a need to find the carriage returns distinctly from other line break characters.

Can someone, anyone, try to match \r AND \x0D in there sublime text in a file they know contains such characters?
For windows, those files are easy to make. Notepad. Enter key makes carriage return + newline = 0D 0A = \r\n

Thank you anyone :smile:


Display line endings, line by line, like in Scintilla

I pretty sure that buffer never contains “\r”, only “\n”.
When ST2 read a file, line endings are normalized to “\n” and ST2 remember what it was before (Windows, linux or Mac)
When the file is write back to disk, “\n” are replaced by the corresponding line endings.

If you have a file with mixed line endings, ST2 will probably normalize them (and you have a problem).



Hey thanks bizoo. What I have experienced can all be explained by what you have said. I am satisfied with that and will not have to have an unpleasant puzzle in my head.

Ya, for sure. And that’s another problem solved. I have many times saved a file in ST2 that looks good with normal lines breaks. Upon opening the file next time, surprise - every second line is blank! Yes, a problem. Yes, a mess!

Many thanks amigo :smile:.