Reply to topic  [ 3 posts ] 
Entering formated text into a Find Replace macro 
Author Message

Joined: 2007-04-12 14:59:36
Posts: 229
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".)


2007-04-30 00:43:07
Profile
User avatar

Joined: 2007-02-07 00:58:12
Posts: 876
Location: Japan
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


2007-04-30 06:36:07
Profile
Official Nisus Person
User avatar

Joined: 2002-07-11 17:14:10
Posts: 4251
Location: San Diego, CA
Post 
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.


2007-04-30 14:48:17
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 3 posts ] 

Who is online

Users browsing this forum: Bing [Bot] and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group
Designed by ST Software