Delete repetitive spaces

Everything related to our flagship word processor.
Post Reply
NisusUser
Posts: 335
Joined: 2011-01-12 05:32:38

Delete repetitive spaces

Post by NisusUser »

Well, this must be a real Newbie question. I have a text with sometimes two or more white spaces where only one should be. I cannot get any of the three ways of doing search and replace in NWP (1.4.2) to replace them. I was used to Word (Win) where you just type in spaces in the find box and then the number of spaces you want to replace them with in the replace box, and it works. For whatever reason, that doesn't work (for me at least) in NWP.
Groucho
Posts: 497
Joined: 2007-03-03 09:55:06
Location: Europe

Re: Delete repetitive spaces

Post by Groucho »

Hi, NisusUser

Open Find/Replace. Select PowerFind Pro from the Using: pop-up. In the Find What field type the following:

Code: Select all

  +
(Note: hit the spacebar twice and then type a plus sign.)

In the Replace With field type:

Code: Select all

 
(Hit the spacebar once.)

Any trouble let me know.

Cheers, Henry.
User avatar
martin
Official Nisus Person
Posts: 5230
Joined: 2002-07-11 17:14:10
Location: San Diego, CA
Contact:

Re: Delete repetitive spaces

Post by martin »

NisusUser wrote:I was used to Word (Win) where you just type in spaces in the find box and then the number of spaces you want to replace them with in the replace box, and it works. For whatever reason, that doesn't work (for me at least) in NWP.
This should work in NWP just fine, eg: if you type two spaces into the "find what" field, one space into the "replace with" field, and click "Replace All", that will collapse all two space sequences in your document to a single space.

Perhaps you have some exotic spaces in your document (eg: a thin space)? If so, you could use a PowerFind expression like this:
replace.png
replace.png (16.72 KiB) Viewed 5658 times
You can insert those bubbles using the little "gear icon" button next to the "find what" field. From that button, use the menus Wild Card > Any Space and Repeat > 1+. Once you have the (AnySpace)(1+) expression, just type a single space into the "replace with" field, and then click "Replace All" to zap all spaces in your document.

If you still have trouble, let us know.
NisusUser
Posts: 335
Joined: 2011-01-12 05:32:38

Re: Delete repetitive spaces

Post by NisusUser »

Thank you both, Henry and Martin. I'll try both ways. I think, Martin, that I did what you said except that I didn't know about the 1+ gizmo. I can't look at it today, but maybe tomorrow. Thanks again!
Groucho
Posts: 497
Joined: 2007-03-03 09:55:06
Location: Europe

Re: Delete repetitive spaces

Post by Groucho »

Alternatively, you can use this macro. It affects a selected text, if any. If there is no selection, the whole document is fixed.

Henry.
FixSpaces.zip
(3.2 KiB) Downloaded 740 times
User avatar
martin
Official Nisus Person
Posts: 5230
Joined: 2002-07-11 17:14:10
Location: San Diego, CA
Contact:

Re: Delete repetitive spaces

Post by martin »

Thanks for the macro Henry.
NisusUser wrote:I think, Martin, that I did what you said except that I didn't know about the 1+ gizmo. I can't look at it today, but maybe tomorrow. Thanks again!
Sure thing.

The "1+" bubble is just the PowerFind way of saying "match one or more of the thing that comes just before". In this case, match one or more of the "Any Space" bubble. But you don't need need to get fancy with PowerFind if you don't want to. You could just type in two regular spaces and replace them with a single space.
Post Reply