[OS X TeX] line breaks \n vs. \r ???
Andrew Miller
ajmiller at psu.edu
Mon Dec 17 23:30:52 CET 2007
On Dec 17, 2007, at 3:45 PM, Steffen Wolfrum wrote:
>
> Am 17.12.2007 um 21:12 schrieb Charilaos Skiadas:
>
>>
>> On Dec 17, 2007, at 2:51 PM, Steffen Wolfrum wrote:
>>
>>>
>>> Am 17.12.2007 um 19:52 schrieb Maarten Sneep:
>>>
>>>>
>>>> On 17 dec 2007, at 18:36, Aaron Jackson wrote:
>>>>
>>>>> On Dec 17, 2007, at 12:05 PM, Steffen Wolfrum wrote:
>>>>>
>>>>>> Hi,
>>>>>>
>>>>>> when editing in TextWrangler a line break is found when using
>>>>>> Grep and search for \r.
>>>>>> In TeXShop a line break is found when using Regular
>>>>>> Expressions and searching for \n: \r gives no result!
>>>>>>
>>>>>> Now, I thought there are "More Options" ... "Serach syntax" can
>>>>>> be changed.
>>>>>> But when I change here also to "Grep" then \r doesn't find line-
>>>>>> breaks but the letter r !!
>>>>>>
>>>>>> Is this a bug in TeXShop 2.14 ?
>>>>>
>>>>> Not a bug. In Mac text files lines end in \r. In Unix text
>>>>> files lines end in \n. In windows text files lines end in \r
>>>>> \n. TextWrangler must save files in mac format while TeXShop
>>>>> saves them in Unix format. You can do a search for (\r(\n)?|\n)
>>>>> and that will find end of lines in all of the text file types.
>>>>
>>>> Not quite: TextWrangler (and BBedit) will use \r for a linebreak,
>>>> no matter what the file is set to use when saving.
>>>
>>>
>>> Right, that's exactly the problem! As I need to perform the same
>>> regex search/replace actions sometimes with TextWrangler,
>>> sometimes with TeXShop I need to have the same syntax, i.e. line-
>>> ending syntax.
>>>
>>> Just, how do I gap the distance between TS's UNIX and TW's Mac
>>> format ?
>>>
>>
>> I have to say I don't see why you feel the need to be able to do
>> the same thing in two different systems. Why have the two systems
>> then? Presumably you need both because there are some thing one can
>> do that the other can't, but in that case you could consider this
>> as one of those things. But I guess I don't have any idea what your
>> workflow is like.
>> In any case, doesn't Aaron's suggestion of using (\r(\n)?|\n) work?
>> I would expect that to work in both systems.
>
>
> Why should someone start to rewrite his collection of regexp search/
> replace-strings when there is still a little hope that he can
> continue using them with the other program? Honestly, I really hoped
> that someone just says »right, you can also set this option there«.
> I didn't expect the applications to be so ... narrow-minded ;o)
>
BBEdit and Text Wrangler internally represent all line breaks with \r
(Carriage Returns) probably because of their Classic Mac heritage.
Having written a Language Module plug-in for BBEdit, I've had to use
\r to match line endings as well. Maybe you should contact BareBones
with a feature request to optionally match \n for line breaks. My
guess is that BBEdit just passes it's internal representation of the
file to whatever regular expressions engine it uses without converting
it back to it's native file format.
BareBones should probably also change the label "Use Grep" in the
"Find & Replace" dialog to "Use Regular Expressions" since the unix
grep command returns whole lines containing the pattern, and not
selections matching the pattern.
-- Andrew
More information about the macostex-archives
mailing list