Spacing at ends of sentences.

Have a problem? A question? This is the place for answers from other Express users.
Post Reply
wolfcreekads
Posts: 23
Joined: 2004-12-15 10:16:29

Spacing at ends of sentences.

Post by wolfcreekads »

When I get manuscripts for stories in our local outdoors publication, many writers will double or even triple space after the end of a sentence. I then have to go through and manually change these to single spaces.

Is there any way that Xpress can do this automatically for the entire document?
cchapin
Posts: 424
Joined: 2004-02-25 18:28:40
Location: Nagoya, Japan

Post by cchapin »

PowerFind or PowerFind Pro should do what you want.

Using PowerFind, in the "Find What" space type two spaces, then click the gear menu, then Repeat #, then 1+. In the "Replace With" space type a single space. Click Replace All.

Using PowerFind Pro, type space, space, plus ( +) in the "Find What" space and space ( ) in the "Replace With" space. Click Replace All.

--Craig
dshan
Posts: 334
Joined: 2003-11-21 19:25:28
Location: Sydney, Australia

Spaces at End of Sentences

Post by dshan »

Here's a macro to do the job. It removes excess spaces (i.e. 2 or more) following periods in the current document, replacing them with a single space, and creates a new document containing the modifed text (so you still have the original document available, just in case). It won't remove extra spaces between words that are part of the same sentence however, if you require that it can be easily modified:

Code: Select all

#Nisus Macro Block
#source front
#destination new
#End Nisus Macro Block
while (my $line = <>) {
	$line =~ s/(\.)(\s){2,}/\. /g;
	print $line;
}
michiganuser19
Posts: 23
Joined: 2010-11-06 08:10:38

remove extra spaces throughout?

Post by michiganuser19 »

I'm using the newest version of NWP, and wanted to get rid of extra spaces in a document. I found this very old thread in the forums; but unfortunately I'm not a macro author (yet), so am not quite sure how to take up the suggestion at the very end.

The details of my issue. I've just been sent a file that includes extra spaces scattered throughout the text. Sometimes these come at the start of a sentence, but more commonly they are simply appearing between words -- e.g., 3 or 4 spaces between two words. I'm not sure why or how the author did this, but she did. Anyway, I need to edit this (long) text, so it would be very welcome to automate some of this work.

I need to KEEP two spaces at the start of each sentence (i.e., after each period), but to maintain only one space between words everywhere else. Is there a macro available that would do so?

Under the existing macros (the ones that came with NWP), I see "cleanup punctuation" -- would that include this space-fixing? I don't see a description for that macro (listing what it would do) in the help file, or in the forums. Thanks!
User avatar
martin
Official Nisus Person
Posts: 5227
Joined: 2002-07-11 17:14:10
Location: San Diego, CA
Contact:

Re: remove extra spaces throughout?

Post by martin »

michiganuser19 wrote:I need to KEEP two spaces at the start of each sentence (i.e., after each period), but to maintain only one space between words everywhere else. Is there a macro available that would do so?
Not offhand, but it's quick enough to make one (I used PowerFind Pro and the "macroize" feature):

Code: Select all

Find and Replace '(?<![\\.!?]) {2,}', ' ', 'Ea'
It replaces all cases of 2 or more spaces that are not preceded by a period, exclamation, or question mark with a single space. Let me know if it gives you any trouble.
michiganuser19
Posts: 23
Joined: 2010-11-06 08:10:38

Re: Spacing at ends of sentences.

Post by michiganuser19 »

Thanks very much! That's really terrific. And it does precisely what I need.

Is there a listing somewhere of the (presumably multiple) changes that would be made by the predefined macro "clean up punctuation"?

Thanks again --
User avatar
martin
Official Nisus Person
Posts: 5227
Joined: 2002-07-11 17:14:10
Location: San Diego, CA
Contact:

Re: Spacing at ends of sentences.

Post by martin »

If you open the macro for editing, the comments (after the "#" sign) somewhat list the changes, eg:

Code: Select all

Find and Replace ‘  +‘, ‘ ‘, ‘aE’ #Replace multiple spaces with one,
Find and Replace ‘([,;:\!\?])\1+‘, ‘\1‘, ‘aE’ #Remove duplicate consecutive punctuation
...
Post Reply