I'm afraid I'm new to all this, so bear with me please...
I have a document to which I have applied strikethroughs to indicate sections that have been superceded. I want to select and delete these sections to produce 'clean' text for the next version of the document.
I bought 'pro' as it allows searching with attributes - but it can't seem to search for >any text with a given attribute< - in any case, there seems no way within the 'find' system to describe the attribute I want.
So I think that a macro may do it, but again, I can't find any way to refer to the strikethrough attribute.
Can anyone help?
Thanks!
find and replace by attribute
- martin
- Official Nisus Person
- Posts: 5228
- Joined: 2002-07-11 17:14:10
- Location: San Diego, CA
- Contact:
Re: find and replace by attribute
You don't need a macro for this. Here's what to do:
1. Open the Find & Replace window.
2. Use the "gear" button under "find what" to insert the PowerFind bubble Wild Card > Any Text.
3. Select the bubble in the "find what" field.
4. Make sure the menu Format > Any Attributes is checked. This is to ensure you don't have any unwanted stray attributes present.
5. With the PowerFind bubble still selected, use the menu Format > Strikethrough > Single.
That last step should automatically turn on the "attribute sensitive" option underneath the find field. Now just press the "Next" or "Find All" button.
1. Open the Find & Replace window.
2. Use the "gear" button under "find what" to insert the PowerFind bubble Wild Card > Any Text.
3. Select the bubble in the "find what" field.
4. Make sure the menu Format > Any Attributes is checked. This is to ensure you don't have any unwanted stray attributes present.
5. With the PowerFind bubble still selected, use the menu Format > Strikethrough > Single.
That last step should automatically turn on the "attribute sensitive" option underneath the find field. Now just press the "Next" or "Find All" button.
Re: find and replace by attribute
Thanks, Martin - a door has been unlocked to me!
Follow-up: find and replace by attribute
Dear all,
I've got a follow-up question. A macro would save a lot of time in the long run since it's several steps, in my case the transformation of certain abbreviations from small caps to CAPS.
(for me, it's a follow-up to my "CAPS to small caps" thread below, to have simple commands for both directions)
What I'd like to have is a macro that finds all text displayed as small caps and transforms it to CAPS.
The search in first line is for a specific kind of abbreviations (grammatical glosses).
The last four lines should work for the transformation.
But how do I find the small caps in the first place?
I can't figure out how to add the 'display as …'.
XXX $numFound = Find All '[a-z]{2,}|[mfn](?=[-:.) /=])', 'E-is'
if $numFound > 0 # Just 'if $numFound' will do the same
Menu "Display as lowercase"
Menu "To UPPERCASE"
end
Btw, I use 'display as small caps' because there was some issue with 'convert to caps' and some fonts.
Thanks for any help and sorry if I've missed an obvious explanation.
thyx
I've got a follow-up question. A macro would save a lot of time in the long run since it's several steps, in my case the transformation of certain abbreviations from small caps to CAPS.
(for me, it's a follow-up to my "CAPS to small caps" thread below, to have simple commands for both directions)
What I'd like to have is a macro that finds all text displayed as small caps and transforms it to CAPS.
The search in first line is for a specific kind of abbreviations (grammatical glosses).
The last four lines should work for the transformation.
But how do I find the small caps in the first place?
I can't figure out how to add the 'display as …'.
XXX $numFound = Find All '[a-z]{2,}|[mfn](?=[-:.) /=])', 'E-is'
if $numFound > 0 # Just 'if $numFound' will do the same
Menu "Display as lowercase"
Menu "To UPPERCASE"
end
Btw, I use 'display as small caps' because there was some issue with 'convert to caps' and some fonts.
Thanks for any help and sorry if I've missed an obvious explanation.
thyx
Thomas Hanke
Re: find and replace by attribute
I guess, what I need is in line with Kino's explanation over there:
http://www.nisus.com/forum/viewtopic.php?f=17&t=3089
But I'm sorry that I can't grasp how there to here, i.e. 'display as …'.
thyx
http://www.nisus.com/forum/viewtopic.php?f=17&t=3089
But I'm sorry that I can't grasp how there to here, i.e. 'display as …'.
thyx
Thomas Hanke
Got it! I think…: find and replace by attribute
Heureka… I guess I found the solution.
I've read some more and found among others Kino's mentioning of "Set Find Shown":
http://www.nisus.com/forum/viewtopic.php?f=17&t=3185
Then it took me some time to realize how useful "Set Find Shown true" is.
Anyway, after some more experimenting I came up with the following.
I’m glad for any comments.
I think I finally got the 'Find and Replace' options all right. That works for all occurrences of one or more letter in the present selection.
I didn't get that far without the "Set Find Shown true/false" part.
Is it just me or is that part of Nisus not (yet) described systematically?
Google has just three hits, all from Kino:
http://www.google.com/search?client=saf ... 8&oe=UTF-8
Thanks, once again, to Kino!
Sorry if this is obvious for anyone, but I haven't found any documentation.
Mmh, that access to the find format could be useful for a lot of things…
thyx
I've read some more and found among others Kino's mentioning of "Set Find Shown":
http://www.nisus.com/forum/viewtopic.php?f=17&t=3185
Then it took me some time to realize how useful "Set Find Shown true" is.
Anyway, after some more experimenting I came up with the following.
I’m glad for any comments.
Code: Select all
Find and Replace '[a-z]+', '\0', 'EiuUas'
Set Find Shown true
Menu "remove attributes and styles"
Menu "Format:Character Case:Display as Small Caps"
Menu ":Edit:Find:Find All"
Set Find Shown false
Menu "remove attributes except styles"
Menu "To uppercase"
I didn't get that far without the "Set Find Shown true/false" part.
Is it just me or is that part of Nisus not (yet) described systematically?
Google has just three hits, all from Kino:
http://www.google.com/search?client=saf ... 8&oe=UTF-8
Thanks, once again, to Kino!
Sorry if this is obvious for anyone, but I haven't found any documentation.
Mmh, that access to the find format could be useful for a lot of things…
thyx
Thomas Hanke
- martin
- Official Nisus Person
- Posts: 5228
- Joined: 2002-07-11 17:14:10
- Location: San Diego, CA
- Contact:
Re: Got it! I think…: find and replace by attribute
Glad you made it- always satisfying to get something working! I have a couple of comments/tips that may be helpful.
First, you are missing the "!" option, which sets the Find & Replace window to use the options/patterns you've specified in the macro command instead of actually running a find/replace operation. If you do not include it, the "Find All" command you issue later will just find whatever happened to be in the find window previously.
Also, the "U" option, to do attribute sensitive replacement, is superfluous because you don't actually need to do any replacing. Instead you're simply modifying the attributes of the found text via the menus.
So, the modified macro becomes:
I would also offer up the following alternative macro, which is slightly more efficient and leaves the Find & Replace window unchanged:
The trick with that macro is you must apply the proper attributes to the find pattern. In your case you want the "Display as Small Caps" attribute present, and no others. To do that select the entire first line of the macro (eg: the entire Find All command), then apply the following menus:
1. Format > Remove Attributes and Styles (this will apply the Normal paragraph style, if it exists)
2. Format > Paragraph Style > Remove Style
3. Format > Character Case > Display as Small Caps
The first two menus ensure that no attributes are applied to the expression, and the second applies the attribute you want to match.
The options you give to the command aren't exactly what you want.thyx wrote:Code: Select all
Find and Replace '[a-z]+', '\0', 'EiuUas'
First, you are missing the "!" option, which sets the Find & Replace window to use the options/patterns you've specified in the macro command instead of actually running a find/replace operation. If you do not include it, the "Find All" command you issue later will just find whatever happened to be in the find window previously.
Also, the "U" option, to do attribute sensitive replacement, is superfluous because you don't actually need to do any replacing. Instead you're simply modifying the attributes of the found text via the menus.
So, the modified macro becomes:
Code: Select all
Find All '[a-z]+', 'Eiuas!'
Set Find Shown true
Menu "remove attributes and styles"
Menu "Format:Character Case:Display as Small Caps"
Menu ":Edit:Find:Find All"
Set Find Shown false
Menu "remove attributes except styles"
Menu "To uppercase"
Code: Select all
Find All '[a-z]+', 'Eiuas'
Menu "remove attributes except styles"
Menu "To uppercase"
1. Format > Remove Attributes and Styles (this will apply the Normal paragraph style, if it exists)
2. Format > Paragraph Style > Remove Style
3. Format > Character Case > Display as Small Caps
The first two menus ensure that no attributes are applied to the expression, and the second applies the attribute you want to match.
Yes, Kino's examples are a great resource. We do have the Nisus Macro Reference, which is included in the NWP disk image or available for download in the macro repository. It lists all available macro commands, even if it doesn't necessarily explain how they might be useful.Is it just me or is that part of Nisus not (yet) described systematically?
Google has just three hits, all from Kino