Replace Highlighting

Get help using and writing Nisus Writer Pro macros.
Post Reply
catstretch
Posts: 3
Joined: 2008-12-07 00:16:13

Replace Highlighting

Post by catstretch » 2008-12-07 00:50:26

I have what I hope is a simple question. All I'm trying to do is set up a sequence of find/replace operations so that the found string is replaced with the same string highlighted. The problem I am having is I can't figure out to to do the highlighting. If I do it in the macros it doesn't transfer over.

Anyone have a simple answer for this? :)

Thanks

catstretch
Posts: 3
Joined: 2008-12-07 00:16:13

Re: Replace Highlighting

Post by catstretch » 2008-12-07 00:59:36

Related question. I'm a newbie and trying to figure out this newbie thing. The problem I am having is that the manual says find and replace should be structured:

Find/Replace`"Find`Pattern"`"Replacement`Pattern" "Options"

But I've figured out that it really needs to be:

Find and Replace 'Find Pattern', 'Replacement Patters', 'Options'

Am I missing something incredibly obvious, is the guide an old version, or is this just something any person with minimal programming experience would know? I'm a little worried I'm going to try and keep learning directly from the manual and I'll learn its "Find and Replace" not "Find/Replace" for just about everything. I'd love to avoid that confusion.

Anyone that give give insight or advice on how to learn this, I'd be grateful.

Groucho
Posts: 496
Joined: 2007-03-03 09:55:06
Location: Europe

Re: Replace Highlighting

Post by Groucho » 2008-12-07 02:16:58

catstretch wrote:Related question. I'm a newbie and trying to figure out this newbie thing. The problem I am having is that the manual says find and replace should be structured:

Find/Replace`"Find`Pattern"`"Replacement`Pattern" "Options"

But I've figured out that it really needs to be:

Find and Replace 'Find Pattern', 'Replacement Patters', 'Options'
Hi, Catstretch.

The second pattern is right. You can use single or double quotes, straight or curly.
By the way, where in the manual did you find the first pattern?

As for the highlight, if you want to highlight some text through a macro you can use this simple code:

Code: Select all

Find "Find_Text", "a"
Format:Highlight:Yellow
Change Yellow with whatsoever color you prefer.

Cheers, Henry.

catstretch
Posts: 3
Joined: 2008-12-07 00:16:13

Re: Replace Highlighting

Post by catstretch » 2008-12-07 09:14:16

I found it on page 365 of the User's Guide.

Is there a way for me to know what colors are available? More importantly, is there a way for me to highlight multiple words and either highlight them at the same time or one after another? I've tried a few different ways and I only ever get one of the find searches I do to highlight.

Than you a lot for your help.
- Catstretch

Groucho
Posts: 496
Joined: 2007-03-03 09:55:06
Location: Europe

Re: Replace Highlighting

Post by Groucho » 2008-12-08 02:24:18

Available colors are listed in Format > Highlight. If you click on Show Highlight Colors you can set a custom color of your liking from the system color picker.
If you want to highlight occurrences one by one you had better use the Find and Replace command under Edit menu. Enable PowerFind Pro and digit as follows:

Find what: Text_to_search
Replace with: \0

Then select \0 and go to Format > Highlight > Yellow (or another color).
Click on Next and then either Replace and Find, if you want to highlight found text, or Next, if you don't want to highlight it.

I hope this will do the job.

Cheers, Henry

User avatar
martin
Official Nisus Person
Posts: 4291
Joined: 2002-07-11 17:14:10
Location: San Diego, CA
Contact:

Re: Replace Highlighting

Post by martin » 2008-12-08 13:03:24

catstretch wrote:I found it on page 365 of the User's Guide.
Perhaps you have an old copy of the User Guide; in the current guide that page is a listing in the index. You can always get to the most recent copy of the guide by choosing the menu Help > Nisus Writer Pro Help.
Is there a way for me to know what colors are available?
As Henry mentioned the colors are listed on the menu Format > Highlight. You might also check the menu Format > Background Color, which has more choices.

If you're looking for even finer control, you can create your own colors in the macro by specifying the exact mix of red/green/blue (RGB). An example that marks text with a lighter blue color:

Code: Select all

Find All "blue"
$color = Color.newWithRGB(0.2, 0.7, 1.0)
Set Background Color $color
More importantly, is there a way for me to highlight multiple words and either highlight them at the same time or one after another?
Sure, just chain together multiple find commands:

Code: Select all

Find All "yellow"
:Format:Highlight:Yellow

Find All "red"
:Format:Background Color:Red

Find All "blue"
$color = Color.newWithRGB(0.2, 0.7, 1.0)
Set Background Color $color

Post Reply