How to delete multiple occurrences of identical paragraphs?

Get help using and writing Nisus Writer Pro macros.
Post Reply
Þorvarður
Posts: 248
Joined: 2012-12-19 05:02:52

How to delete multiple occurrences of identical paragraphs?

Post by Þorvarður » 2015-02-05 04:50:02

Does anyone have a macro that deletes multiple occurrences of identical paragraphs?

From the following list (or paragraphs) I would like to be able to delete "Old Japanese literature" with a macro:
Modern Japanese literature
Japanese literature
Old Japanese literature
Old Japanese literature
Old Japanese literature
Old Japanese literature
Old Japanese literature
English literature
so that the list will look like this:
Modern Japanese literature
Japanese literature
Old Japanese literature
English literature

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

Re: How to delete multiple occurrences of identical paragrap

Post by phspaelti » 2015-02-05 05:00:19

Don't need a macro. Find/Replace will do:

Code: Select all

Find and Replace '^(.+\n)\1+', '\1', 'Ea'
Attachments
Find identical paras.jpg
Find identical paras.jpg (40.4 KiB) Viewed 3198 times
philip

Þorvarður
Posts: 248
Joined: 2012-12-19 05:02:52

Re: How to delete multiple occurrences of identical paragrap

Post by Þorvarður » 2015-02-06 02:02:55

Excellent. Thank you, Philip. :-)

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

Re: How to delete multiple occurrences of identical paragrap

Post by adryan » 2015-03-05 18:46:20

G’day, Þorvarður et al

Just for the record, note that Philip’s solution only works when the replicated paragraphs are contiguous. But one can easily ensure this by first using one of the Sort Paragraphs commands in the Edit menu.

Cheers,
Adrian
MacBook Pro (mid-2014)
macOS Sierra 10.12.6
Nisus Writer user since 1996

Post Reply