Billy's Blog

To post pictures and other goodies for free on the net.

My Photo
Name:
Location: Utah, United States

Born in Kapiolani Children's Medical Center, just a few blocks from Waikiki. Graduated from Kahuku High School. Rode BMX Freestyle for most of my life (more than 20 years), now my 8 year old son is ripping up the skate parks, but plans on getting drafted by the SeaHawks as a WR.

Tuesday, November 27, 2012

Notepad++ and the escaped "\r" vs. "\n"

Some might know that \r\n or CrLf are required in some systems for the carriage return and line feed. Unix and Macs only need one or the other (Unix needs \r and Macs need \n or the other way around, it doesn't matter, I am not worried about those OSs) but in Notepad++ they are ambiguous at times. Sometimes Notepad++ will treat them the same and not really let you know why.

I did a test, and I hope this helps someone out someday (mostly me when I forget again).

When doing a search/replace and you want to add a new line, you can use either \r or \n and it will be treated the same.

When you are searching for just a new line like a period with a [Return] after it, you can search for ".\r" or ".\n" and get the same results.

[Return]Now for the times that it actually makes a difference:
If you are doing a search for a character at the end of a line then a [Return] then another specific character, you must have "\r\n" in that order. For example, today I was looking for an exclamation point followed by a [Return] with another exclamation point starting the next line. For that search I needed to use "!\r\n!" in the search box.

I hope this helps!! ;-)

3 Comments:

Anonymous Anonymous said...

It helped me a lot, thanks!

8/26/2014 2:15 AM  
Anonymous Anonymous said...

and it helped again. Thanks

7/04/2015 10:38 PM  
Blogger Unknown said...

OK, so new versions of NPP might not recognize the \r anymore, or it might be the format of the file I am working on, but it wouldn't let me use the \r, instead it wanted the \n\n

9/14/2015 3:51 PM  

Post a Comment

<< Home