How to delete multiple occurrences of identical paragraphs?

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

How to delete multiple occurrences of identical paragraphs?

Post by Þorvarður »

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

Re: How to delete multiple occurrences of identical paragrap

Post by phspaelti »

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 11049 times
philip
Þorvarður
Posts: 410
Joined: 2012-12-19 05:02:52

Re: How to delete multiple occurrences of identical paragrap

Post by Þorvarður »

Excellent. Thank you, Philip. :-)
adryan
Posts: 561
Joined: 2014-02-08 12:57:03
Location: Australia

Re: How to delete multiple occurrences of identical paragrap

Post by adryan »

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 (M1 Pro, 2021)
macOS Ventura
Nisus Writer user since 1996
Post Reply