Page 1 of 1

find and replace with line break in multiple files

Posted: Sun Jul 19, 2009 11:11 am
by Wolfhart
Hi,

The "Find/Replace" dialog when working on the current file allows for inserting line breaks but the "Find/Replace in Files" dialog does not. Why is that? Is there a way to insert line breaks in multiple files? For example, how could I replace the text

abc/><xyz

with

abc/>
<xyz

in all the files in my project?

Thanks,
Wolfhart

Re: find and replace with line break in multiple files

Posted: Mon Jul 20, 2009 10:28 am
by sorin_ristache
Hello,

As you can read in the tooltip of the Replace field you have to use {$NEWLINE} in the replace expression where you want to insert a newline character.


Regards,
Sorin

Re: find and replace with line break in multiple files

Posted: Wed Jul 22, 2009 6:34 am
by Wolfhart
Thanks!
Wolfhart

Re: find and replace with line break in multiple files

Posted: Mon Aug 24, 2009 11:59 pm
by Wolfhart
Hi again,

One more question: What if I want to reverse the above step, that is, replace

abc/>
<xyz

with

abc/><xyz

in all files in my project? I tried Text to find="abc/>{$NEWLINE}<xyz" and Replace with="abc/><xyz", but that doesn't work.

Thanks,
Wolfhart

Re: find and replace with line break in multiple files

Posted: Tue Aug 25, 2009 11:53 am
by sorin_ristache
That is not possible in the current version because the find expression of the Find/Replace in Files dialog can cover only one line. We plan to enhance it in a future version to cover multiple lines as in the Find/Replace dialog used in a single file (the action from menu Find -> Find/Replace). We will let you know when we will have implemented it.


Regards,
Sorin

Re: find and replace with line break in multiple files

Posted: Wed Jul 11, 2018 7:56 pm
by mandapizz
Hello- has this been fixed/added yet? (your last response)

Re: find and replace with line break in multiple files

Posted: Thu Jul 12, 2018 8:08 am
by Radu
Hi,

Recent versions of Oxygen allow you to search and replace with full multi-line support.
If this does not work for you maybe you can tell us what version of Oxygen you are using and give a small example about what you are trying to do.

Regards,
Radu

Re: find and replace with line break in multiple files

Posted: Mon Jul 16, 2018 5:15 pm
by mandapizz
Hi,

I'm trying to find and replace (with a space, so trying to find and delete) an element that covers multiple lines:
<mods:subject authority="lcsh">
<mods:name type="corporate">
<mods:namePart>InsertNameHere</mods:namePart>
</mods:name>
<mods:topic>Literary collections</mods:topic>
</mods:subject>
I'm using version 20.0. When I try to insert all of this into the find and replace dialog (for multiple files) it only includes the first line: <mods:subject authority="lcsh">

Is there a way to do what I'm hoping to?

Thank you,
Amanda

Re: find and replace with line break in multiple files

Posted: Tue Jul 17, 2018 8:29 am
by Radu
Hi Amanda,

In the Find field you can insert the entire set of tags on one line separated by a single space between the tag names:

Code: Select all

<mods:subject authority="lcsh"> <mods:name type="corporate"> <mods:namePart>InsertNameHere</mods:namePart> </mods:name> <mods:topic>Literary collections</mods:topic> </mods:subject>
and then check the "Ignore Extra Whitespaces" checkbox.

Or fo to the top level Tools menu->XML Refactoring->"Delete element" and use as XPath something like:

Code: Select all

//*:subject[@authority='lcsh'][*:name[@type='corporate'][*:namePart[text() = 'InsertNameHere']]]
I usually consider that XML-aware changes (which involve searching for entire XML elements) should be best done with the XML Refactoring tools because they should find your element no matter how many whitespaces or line breaks you have between the tags of the element.

Regards,
Radu

Re: find and replace with line break in multiple files

Posted: Tue Jul 17, 2018 3:37 pm
by mandapizz
This is great, thank you so much!