Entering formated text into a Find Replace macro

Get help using and writing Nisus Writer Pro macros.
Post Reply
js
Posts: 259
Joined: 2007-04-12 14:59:36

Entering formated text into a Find Replace macro

Post by js »

With an open file I would like to use a macro to find any text in Courier (if there is any) and replace it with Times. This seems simple and the Macro Find language has the u and U for considering attributes. But how can I enter ".+" with font attributes into Find and Replace? (You can of course use "!" to enter the find text and the find and replace arguments into the find window. But this is not formatted text. Nor does it allow you to enter a replace text, like "\0".)
User avatar
phspaelti
Posts: 1313
Joined: 2007-02-07 00:58:12
Location: Japan

Re: Entering formated text into a Find Replace macro

Post by phspaelti »

js wrote:With an open file I would like to use a macro to find any text in Courier (if there is any) and replace it with Times. This seems simple and the Macro Find language has the u and U for considering attributes. But how can I enter ".+" with font attributes into Find and Replace? (You can of course use "!" to enter the find text and the find and replace arguments into the find window. But this is not formatted text. Nor does it allow you to enter a replace text, like "\0".)
I haven't gotten attribute sensitive find to work directly from a macro either. I am assuming it's a bug. (Or perhaps just an unimplemented feature.)

But you can do something like this in macro (variant of an original idea due to Yusuke Kinoshita):

Find '(?:.+|\n)+', 'Eu!'
Show Find
Format:Remove Attributes and Styles
Format:Font:Courier
Find All
Close
Format:Font:Times
User avatar
martin
Official Nisus Person
Posts: 5227
Joined: 2002-07-11 17:14:10
Location: San Diego, CA
Contact:

Post by martin »

All you have to do is apply the Courier font to the find pattern, eg: select the text "(.+)" and apply Courier. You might want to make sure you don't have any other attributes applied to the expression by first choosing the menu Format > Remove Attributes and Styles.

Here's a sample macro that does what you'd like. It could also be written using a single Find and Replace command (instead of using the Format menu) but the current beta is a bit overzealous with replacing attributes. Eg: it uses exactly the attributes applied to the replacement text. This will be fixed before release.
Post Reply