Repeating a selection?
Posted: 2007-11-09 13:40:52
Dear Folks,
I'm new to NWP, long-time user of NW Classic; I'm not used to writing in NWP. Here's my problem:
I want to do repeated search/replaces on a body of selected text. The problem I'm running into is that after one search/replace, the selection changes from the original one to the material replaced. Is there any way to maintain a selection or reselect the old material automatically.
For example, the following macro is supposed to take a basic text file (breaks at the end of each line, double breaks between paragraphs) and turn it into unbroken paragraphs separated by breaks and tabs. It fails because after line 1, because the selected material becomes the double-~'s, not the original selection.
#Combines selected lines into normal paragraphs
Find and Replace '\n\n', '~~', 'Esa' #replaces double CR's with double-~
Find and Replace '\n', ' ', 'Esa' #concatenates lines
Find and Replace '~~', '\n\t', 'Esa' #restores double CR's as para breaks with indents
Find and Replace ' ', ' ', 'Esa' #removes duplicate spaces
A work-around would be to cut the selection, paste it into a new doc window, run the s/r all's on that entire document, select it, cut it, close the window and paste it back into the original. But that's a kludge (and woudn't work on noncontiguous selections) -- I'm hoping there's something more elegant.
Thanks!
pax / Ctein
I'm new to NWP, long-time user of NW Classic; I'm not used to writing in NWP. Here's my problem:
I want to do repeated search/replaces on a body of selected text. The problem I'm running into is that after one search/replace, the selection changes from the original one to the material replaced. Is there any way to maintain a selection or reselect the old material automatically.
For example, the following macro is supposed to take a basic text file (breaks at the end of each line, double breaks between paragraphs) and turn it into unbroken paragraphs separated by breaks and tabs. It fails because after line 1, because the selected material becomes the double-~'s, not the original selection.
#Combines selected lines into normal paragraphs
Find and Replace '\n\n', '~~', 'Esa' #replaces double CR's with double-~
Find and Replace '\n', ' ', 'Esa' #concatenates lines
Find and Replace '~~', '\n\t', 'Esa' #restores double CR's as para breaks with indents
Find and Replace ' ', ' ', 'Esa' #removes duplicate spaces
A work-around would be to cut the selection, paste it into a new doc window, run the s/r all's on that entire document, select it, cut it, close the window and paste it back into the original. But that's a kludge (and woudn't work on noncontiguous selections) -- I'm hoping there's something more elegant.
Thanks!
pax / Ctein