Jump to content

Prevent consecutive spaces


Recommended Posts

One of the best features of  FrameMaker (6) was a preferences option that prevents the typing of consecutive spaces. A professional does not use spaces for formatting. Therefor there is need to have consecutive spaces but it often happens by accident that one types more than one space. So I would to be very happy to have a preferences option that prevents typing (and pasting) consecutive space.

By the way, I tried to add a text replacement in preferences, two spaces to one … Publisher just crashes.

Link to comment
Share on other sites

Hi Matthias Zepf :)

Thanks for your suggestion!

1 hour ago, Matthias Zepf said:

By the way, I tried to add a text replacement in preferences, two spaces to one … Publisher just crashes.

Sorry to hear this, how are you adding this please - through the Auto Correct options? Are you using Mac or Windows please?

Link to comment
Share on other sites

I personally would not rely on auto correct, but rather a quick find/replace after an author has given me the text. Here regular expressions (what InDesign people call GREP) is of great help, and this is already available in Publisher currently. In case you or others reading this are not familiar with regular expressions, here are some suggested patterns that you can save somewhere for use in the Find and Replace Studio (make sure you have turned on Regular Expressions from the gear by the Find field). You should be able to copy these straight from the post and paste them in the FaR studio.

If you only want to replace multiple plain spaces with a single plain space, then paste the following in the find field:

( ){2,}

Enter a single space in the replace field, and it will find all places where there are two or more spaces together. (Technically, the parentheses are not necessary in this search, but I thought it would make it easier to see where the space character is. They are necessary in the following searches.)

If you want to replace multiple of any kind of space (which includes paragraph breaks and tabs), use this:

Find: 

(\s){2,}

Replace:

$1

Explanation: we have the same two or more {2,} notation as before, but this time it is two or more of any kind of white space character, indicated with \s. We have put it inside a pair of parentheses, which identifies it as a capture group. In the replace, we choose to replace the result with $1, which means whatever was found in the first capture group. So two or more tabs will be replaced with one tab; two or more paragraph breaks will be replaced with one paragraph break; two or more non-breaking spaces will be replaced with one non-breaking space. If you have a mix (say one space and one tab), it will replace with the last character (here, one tab).

Be careful on that last point: if you are using tabs for indentation, then a tab at a new paragraph will count as a match, meaning the paragraph break and tab together will get replaced with just a tab, no paragraph break. I much prefer to control indentation with paragraph settings. If someone gives me text with typed tabs for indentation, I just use the following to remove all space at the beginning of a paragraph:

^\s+

Leave the replace field empty. The character denotes the start of a line (here, start of a paragraph), so we are removing one or more (the + symbol) of any whitespace after a new paragraph. Similarly, $ means the end of a line, so you could use $\s+ to remove all trailing whitespace. You could do both of those all at once using the or | symbol to trim both leading and trailing whitespace:

^\s+|\s+$

Finally, I’ll give you what I use for clearing multiple spaces. In my work in French, non-breaking spaces and thin spaces both appear very frequently around punctuation, so I wrote this regex to replace multiple spaces but to prefer the “fancy” spaces over plain spaces. For example, if I have a thin space and a regular space together, replace with one thin space. I have also excluded paragraphs \r, tabs \t, and new lines \n.

Find:

( )*(?![ \r\n\t])(\s)(?![\r\n\t])(\s)*|( ){2,}

Replace

$2$4

(Technical note: The downside to my solution is that it always finds a result on every “fancy” space even if it is just one, and then it replaces it with itself, so that a subsequent replace all finds the same number of results. I would prefer to have a pattern that matches only if more than one total whitespace characters are present, but I haven’t been clever enough to a) prefer any “fancy” space over plain space while replacing, while in the same pattern b) exclude \r\n\t from the pattern. If any of you are cleverer than I, please let me know!)

Summary: using regular expressions is very powerful, and it is a feature that was much requested in this very forum and that Serif implemented before the first release of Publisher (thanks again, Serif!). Now if they take it one step further and let us save our searches, then it would save us time, and it would help people who are not familiar with regex. People could just ask for patterns in forums such as these and then save them for future use with names that make sense to them, such as “delete extra spaces.”

Link to comment
Share on other sites

On 10/2/2019 at 12:25 PM, Matthias Zepf said:

I'm on Mac; see screenshot, two spaces in "Replace" textfield, one space in "With", then click "Add" → Crash.

Thanks for confirming that, this bug appears to affect Mac only and not Windows, so I'll get it logged with our developers now!

Link to comment
Share on other sites

Thanks for all the hints. I'm well aware that the problem can be solved with search/replace, with or without regular expressions — but one has to do it. This is no problem when you are working for days on a document, with some reviews by the client etc. But I (also) use Publisher to create quick small documents, e.g. invoices. Load a template, type some text, print, done. Then I usually forget to do QA with search/replace and that is why I like to have this feature build-in in the typing process.

Link to comment
Share on other sites

  • 4 weeks later...
  • Staff

We believe the issue "Adding Auto Correct option for double space to singular space crashes app" has been fixed in 1.8.0 [Publisher beta is currently available if you care to check]. 

Patrick Connor
Serif Europe Ltd

"There is nothing noble in being superior to your fellow man. True nobility lies in being superior to your previous self."  W. L. Sheldon

 

Link to comment
Share on other sites

In some of mine topics I wrote how FrameMaker deals with extra unnecessary space:

  1. before a character
  2. after a character
  3. both.

If A-Team is interested of that I could find it and reactivated it again.

All the latest releases of Designer, Photo and Publisher (retail and beta) on MacOS and Windows.
15” Dell Inspiron 7559 i7 Windows 10 x64 Pro Intel Core i7-6700HQ (3.50 GHz, 6M) 16 GB Dual Channel DDR3L 1600 MHz (8GBx2) NVIDIA GeForce GTX 960M 4 GB GDDR5 500 GB SSD + 1 TB HDD UHD (3840 x 2160) Truelife LED - Backlit Touch Display
32” LG 32UN650-W display 3840 x 2160 UHD, IPS, HDR10 Color Gamut: DCI-P3 95%, Color Calibrated 2 x HDMI, 1 x DisplayPort
13.3” MacBook Pro (2017) Ventura 13.6 Intel Core i7 (3.50 GHz Dual Core) 16 GB 2133 MHz LPDDR3 Intel Iris Plus Graphics 650 1536 MB 500 GB SSD Retina Display (3360 x 2100)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.