find and replace with line break in multiple files

Having trouble installing <oXygen/>? Got a bug to report? Post it all here.
Wolfhart
Posts: 31

find and replace with line break in multiple files

Sun Jul 19, 2009 11:11 am

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
sorin_ristache
Posts: 4144

Re: find and replace with line break in multiple files

Mon Jul 20, 2009 10:28 am

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
Wolfhart
Posts: 31

Re: find and replace with line break in multiple files

Wed Jul 22, 2009 6:34 am

Thanks!
Wolfhart
Wolfhart
Posts: 31

Re: find and replace with line break in multiple files

Mon Aug 24, 2009 11:59 pm

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
sorin_ristache
Posts: 4144

Re: find and replace with line break in multiple files

Tue Aug 25, 2009 11:53 am

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
mandapizz
Posts: 4

Re: find and replace with line break in multiple files

Wed Jul 11, 2018 7:56 pm

Hello- has this been fixed/added yet? (your last response)
Radu
Posts: 5692

Re: find and replace with line break in multiple files

Thu Jul 12, 2018 8:08 am

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
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
mandapizz
Posts: 4

Re: find and replace with line break in multiple files

Mon Jul 16, 2018 5:15 pm

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
Radu
Posts: 5692

Re: find and replace with line break in multiple files

Tue Jul 17, 2018 8:29 am

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
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
mandapizz
Posts: 4

Re: find and replace with line break in multiple files

Tue Jul 17, 2018 3:37 pm

This is great, thank you so much!

Return to “Common Problems”

Who is online

Users browsing this forum: No registered users and 3 guests