Request: Find all by Formatting Examiner within selection

Everything related to our flagship word processor.
Post Reply
withoutFeathers
Posts: 140
Joined: 2013-03-19 16:22:50

Request: Find all by Formatting Examiner within selection

Post by withoutFeathers »

Greetings,
I have a regular need to find all the text of a given colour within a selection.
I believe Nisus can't do this. At least, I haven't found a way in either the Find dialog or the Formatting Examiner.

If not, it occurs to me it would be nice if Nisus could add a function in the Formatting Examiner, in the gear menu, that said:
"Find all within selection".
Then I could find any of the Examiner's attributes within a selection. :)

To be clear, here's an example:
1. Say my file is 100 pages of text.
2. I'm Editing one 10-page chapter of it.
3. Scattered in that chapter are 20 or 30 passages that are in a given colour (say blue).
4. I want to select them all at once, so I can change them to green.

5. Formatting Examiner will select all the blue in the whole 100 pages, but not the 10 pages, as far as I can figure out.
6. "Find" will find within a selection, but not by colour, as far as I can figure out.

Anything I'm missing?

wF
User avatar
phspaelti
Posts: 1313
Joined: 2007-02-07 00:58:12
Location: Japan

Re: Request: Find all by Formatting Examiner within selection

Post by phspaelti »

Find most certainly can find blue color, or any other such feature, and it can do this within a selection.
  1. Open Find and in the dialog enter "AnyText" (You must be in PowerFind or PowerFind Pro).
  2. Select the "AnyText" and apply the feature you want to look for. (This should put a check in "Formatting Senstive". If not, make sure to check it.)
  3. Choose "In Selection"
  4. Click on "Find All"
philip
adryan
Posts: 561
Joined: 2014-02-08 12:57:03
Location: Australia

Re: Request: Find all by Formatting Examiner within selection

Post by adryan »

G'day, wF et al

I see Philip has posted a reply while I was composing mine, but I'll post mine anyway because it adds a few details that might prove helpful.

You should be able to do this from within the Find/Replace system. It takes longer to describe it than to do it, but I've spelt it out in detail in case it's of help to anyone.

Using PowerFind Pro, set the expression in the "Find what" field to ".+", omitting the quotation marks (so it's just the two characters). Generally speaking, this expression just means "a string of one or more consecutive characters".

Select those two characters and format them as desired. You could (for example) italicize them, color them, specify their font — or any combination of these. If you want to specify the text color, it might be best to use the Format menu because you need to disable the possibility of "Any Text Color" being selected in the Text Color sub-menu. (At one stage that menu item remained ticked even when I changed the color via a Palette.)

You want to search "In Selection" and with the "Formatting Sensitive" checkbox ticked. Click on the "Find All" button. You can then do whatever you want with the found item(s) which will be highlighted (eg, change their color).

If you wish, you can streamline things a bit by setting the expression in the "Replace with" field to "\0", omitting the quotation marks (so it's just the backslash and a zero). This expression just means "everything returned from the Find operation". Select those two characters and format them as desired (eg, specify a different color from that in the "Find what" field). Tick the "Replace Formatting" checkbox and click on the "Replace All" button. That will change the document text in the way you want.

You can streamline things even more by Macroizing the Replace operation.

As always, with complex operations on large documents it's best to do it on a copy in the first instance.

Cheers,
Adrian
MacBook Pro (M1 Pro, 2021)
macOS Ventura
Nisus Writer user since 1996
withoutFeathers
Posts: 140
Joined: 2013-03-19 16:22:50

Re: Request: Find all by Formatting Examiner within selection

Post by withoutFeathers »

Greetings both,

Thank you both. I've worked through both of them and I'm amazed. :)

Either way does exactly what I want. And I applied Adrian's Replace in PowerFind Pro to Philip's PowerFind, by using the "Found" function and applying the new colour to it. Great to know all this.

I looked at "Macroize", but I'm assuming that since my need is so simple -- a single term in Find and Replace both -- that making a macro would be more trouble than it's worth. Though correct me if I'm wrong there.

Thank you again for this. Do you know, did this appear in version 3 at the same time the Formatting Examiner was added, or have these capabilities been there since version 2? I haven't thoroughly read the 3 manual.

wF
adryan
Posts: 561
Joined: 2014-02-08 12:57:03
Location: Australia

Re: Request: Find all by Formatting Examiner within selection

Post by adryan »

G'day, wF et al

This sort of thing has been available in the Find/Replace system for ages.

If you think you might use a procedure more than once, it's often worth creating a Macro for it, especially if it contains multiple steps and/or you're unlikely to recall in future how you went about it in the first place. In short, the more time-consuming it would be to recreate a procedure, the more worthwhile it is to save it as a Macro for future use.

In the case of a Find/Replace operation, you simply choose "Macroize…" from the drop-down menu that appears when you click on one of the cogwheel buttons in the Find & Replace dialog box.

In the case of this color changing operation, you would choose the "Replace All" action and Save As Macro to the Changing Text group of Macros (or wherever else you thought fit). Name it something helpful like "Blue to Green in Selection".

Cheers,
Adrian
MacBook Pro (M1 Pro, 2021)
macOS Ventura
Nisus Writer user since 1996
withoutFeathers
Posts: 140
Joined: 2013-03-19 16:22:50

Re: Request: Find all by Formatting [Examiner] within selection

Post by withoutFeathers »

adryan wrote: 2021-11-09 14:39:00 In the case of this color changing operation, you would choose the "Replace All" action and Save As Macro to the Changing Text group of Macros (or wherever else you thought fit). Name it something helpful like "Blue to Green in Selection".
Thanks for this. It was much easier than I expected.

And it even repeats using the Command-R function, which is nice.

And, I've now set a Menu Key option for it, as Command-G. Wow, that's as easy as it gets.

:D

wF
adryan
Posts: 561
Joined: 2014-02-08 12:57:03
Location: Australia

Re: Request: Find all by Formatting Examiner within selection

Post by adryan »

G'day, wF et al

Very good.

However, I would suggest you choose a different Menu Key option for your Macro, as Command-G is the default combination for "Find Next". That's not to say you can't redefine keystroke shortcuts to perform whatever operation you wish; it's just that it's handy to keep this particular shortcut available for use with the "Find Next” command.

Cheers,
Adrian
MacBook Pro (M1 Pro, 2021)
macOS Ventura
Nisus Writer user since 1996
withoutFeathers
Posts: 140
Joined: 2013-03-19 16:22:50

Re: Request: Find all by Formatting Examiner within selection

Post by withoutFeathers »

adryan wrote: 2021-11-09 17:12:52 However, I would suggest you choose a different Menu Key option for your Macro, as Command-G is the default combination for "Find Next".
O right, I forgot that. Yes, will change.

wF
User avatar
xiamenese
Posts: 543
Joined: 2006-12-08 00:46:44
Location: London or Exeter, UK

Re: Request: Find all by Formatting Examiner within selection

Post by xiamenese »

Can I ask **where** you set Cmd-G as a shortcut? Apple/Preferences or Nisus/Preferences. The latter should have warned you that that was already assigned to Find Next.

On another note, to me one of the great things about the Nisus shortcuts is the ability to use multi-key shortcuts, so they can be quite mnemonic; so for blue —> green, I’d assign Cmd-BG.

:D

Mark
adryan
Posts: 561
Joined: 2014-02-08 12:57:03
Location: Australia

Re: Request: Find all by Formatting Examiner within selection

Post by adryan »

G'day, Mark et al

Yeah, that's better, I think.

Nisus Writer Pro > Preferences > Menu Keys > Edit > Find > Find Next

Cmd-G is set there by default.

That keystroke shortcut is used for the same command in BBEdit and Preview, among others. There is mnemonic value in this assignment.

You can set keystroke shortcuts using System Preferences, but I generally only go down that route for applications (such as Numbers) that don't deal with them themselves.

Cheers,
Adrian
MacBook Pro (M1 Pro, 2021)
macOS Ventura
Nisus Writer user since 1996
User avatar
xiamenese
Posts: 543
Joined: 2006-12-08 00:46:44
Location: London or Exeter, UK

Re: Request: Find all by Formatting Examiner within selection

Post by xiamenese »

I too set shortcuts up in System Preferences for specific apps—like Scrivener—which don't have an internal shortcut system, but am careful not to override standard MacOS shortcuts. For Nisus, I always use the Nisus system as it's so flexible.

After I'd posted my previous message, it struck me that I haven't tried to macroise a search and replace for a long, long time, and I wondered if the pane that comes up to save the macro has a field for entering the shortcut, but which doesn't give the "already assigned" warning, which is why the OP missed it.

:D

Mark
adryan
Posts: 561
Joined: 2014-02-08 12:57:03
Location: Australia

Re: Request: Find all by Formatting Examiner within selection

Post by adryan »

G'day, Mark et al

No, Nisus doesn't offer you the option to assign a keyboard shortcut in the Save dialog box. This applies to any file, not just a Macro. Adding such a facility would, I think, complicate the Save process unnecessarily.

As things stand, attempting to set a pre-assigned keyboard shortcut in NWP's Menu Keys system does flag a conflict (with specific details) which you can resolve as you see fit.

And you're right: with NWP's acceptance of multi-key shortcuts, there's generally little need to expropriate a pre-assigned sequence for use with another command.

Cheers,
Adrian
MacBook Pro (M1 Pro, 2021)
macOS Ventura
Nisus Writer user since 1996
withoutFeathers
Posts: 140
Joined: 2013-03-19 16:22:50

Re: Request: Find all by Formatting Examiner within selection

Post by withoutFeathers »

Hi Mark,
xiamenese wrote: 2021-11-10 00:18:43 Can I ask **where** you set Cmd-G as a shortcut? Apple/Preferences or Nisus/Preferences. The latter should have warned you that that was already assigned to Find Next.
I used Nisus/Preferences. I wondered that myself later. I don't know how I missed it. Either I just didn't see the text at the bottom of the box (which I'll describe now as 'unobtrusive'), or I'd already removed it for some other reason. But that's not likely.
xiamenese wrote: 2021-11-10 00:18:43 On another note, to me one of the great things about the Nisus shortcuts is the ability to use multi-key shortcuts, so they can be quite mnemonic; so for blue —> green, I’d assign Cmd-BG.
WOW! Thanks for this. So now I've set up Cmd-BG. And also Cmd-FB for times I just want to find blue text (say for its word-count) without changing it. And this capability will probably lead me to use macros more. Great.

As a trivia, in the course of doing this I discovered a small bug/peculiarity about the Nisus key shortcuts: apparently they don't follow the macro if you drag it in the Finder to another menu folder. That is: I had mis-filed my Cmd-FB macro at first, and then, after giving it the key-combination, I dragged it to another folder. And Nisus moved it in the menu, but didn't take the Cmd-FB with it, and in fact complained that there already was one when I tried to assign Cmd-FB to it again at the new location. However, since I knew it no longer existed at the old location (and I checked, it wasn't there), I overrode that, and it all works fine now.

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

Re: Request: Find all by Formatting Examiner within selection

Post by martin »

withoutFeathers wrote: 2021-11-10 08:31:36 As a trivia, in the course of doing this I discovered a small bug/peculiarity about the Nisus key shortcuts: apparently they don't follow the macro if you drag it in the Finder to another menu folder. That is: I had mis-filed my Cmd-FB macro at first, and then, after giving it the key-combination, I dragged it to another folder. And Nisus moved it in the menu, but didn't take the Cmd-FB with it, and in fact complained that there already was one when I tried to assign Cmd-FB to it again at the new location. However, since I knew it no longer existed at the old location (and I checked, it wasn't there), I overrode that, and it all works fine now.
That's expected behavior: Nisus Writer records keyboard shortcuts by their menu path. So your shortcut Cmd-FB was recorded for a menu path like "Macro:Some Folder:Your Color Macro". If you move the macro between folders (or rename it) then its path changes and the keyboard shortcut will no longer be correct. You need to fix it manually– sorry for the nuisance.
Post Reply