8

I have some text files copied out to a server. I typically use and prefer notepad++ to look at text files but on this server, only textpad is installed. This is really strange behavior but I noticed that when I view the EOL chars in notepad++ I can clearly see and search for the CRLF (i.e. \r\n). But when I display the same files in textpad, I am able to search only on the LF (\n) and do not have any hits on the CR (\r). Am I missing something on how Textpad is interpreting the EOL chars?

Chris Martin
  • 30,334
  • 10
  • 78
  • 137
Kimberly Ketchum
  • 101
  • 1
  • 2
  • 3
  • Thanks for the reply Kyslik. I don't typically use TextPad but that is what is installed out on the server. When I view the files in notepad++ on my desktop I can see the CRLF (\r\n) and I can search for them. When I view the same files using Textpad and search for CRLF(\r\n) I only get hits on LF(\n) and not CR(\r). Do I have something wrong with my settings or does Textpad just truly interpret CRLF as (\n) instead of (\r\n)? – Kimberly Ketchum Jun 14 '13 at 15:15
  • `newline` differs in all 3 most common operation systems (Windows, Linux and Mac OS) I bet you knew this. `notepad++` as far as I know is much robust and therefore `newlines` are "autodetected" and I bet you can even set how is program "showing" (rendering) them in text area. As it seems yes TextPad interpret CRLF as `\n` even on windows machine. But take a look in [release notes](http://www.textpad.com/support/relnotes.html) of TextPad => `In regular expressions in macros, [^...] is now changed to [^...\r\n] to constrain it to the end of line`. I don't know If I helped. – Kyslik Jun 14 '13 at 15:32

3 Answers3

22

This happens when the EOL control characters are not correct. Windows represents newlines with the carriage return + line feed.

In Notepad++, you can check for these characters by selecting:

View > Show Symbols > [x] Show End of Line

notepad++

You need to modify your script so your data is formatted like this:

CRLF

Adrian Cumpanasu
  • 1,028
  • 1
  • 10
  • 24
2

Yes ideally it's carriage return and followed by line feed,

\r\n

but you can also use a quick shorthand to place {lf} rather then {cr}{lf}

\n

a.c
  • 21
  • 1
1

I know this is a slightly old question, but I struggled with this exact problem, and here is how I found a workaround.

When using Save As in textpad you can specify the file format at the bottom (PC, UNIX, or Mac). If you choose UNIX in theory this ends lines only with the \n character, however you have to change this option every time.

You can change the preferences for specific "Document Classes" to specify the output file format. Follow these steps:

  • Click Configure
  • Go to Preferences
  • Expand the Document Classes list
  • Select bash, which should include *.sh files
  • Scroll down the options on the right until you see Create new files as
  • Select UNIX

This should now save all *.sh files you create as UNIX format without the carriage returns. Good luck

I found this info here: http://homes.ori.org/~keiths/Files/Tips/Software_TextPad_Prefs.html#DocClasses

Luke
  • 643
  • 1
  • 10
  • 17