nisus.com
https://www.nisus.com/forum/

Entering formated text into a Find Replace macro
https://www.nisus.com/forum/viewtopic.php?f=17&t=2207
Page 1 of 1

Author:  js [ 2007-04-30 00:43:07 ]
Post subject:  Entering formated text into a Find Replace macro

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".)

Author:  phspaelti [ 2007-04-30 06:36:07 ]
Post subject:  Re: Entering formated text into a Find Replace macro

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

Author:  martin [ 2007-04-30 14:48:17 ]
Post subject: 

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.

Page 1 of 1 All times are UTC - 8 hours
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/