If there are always at least two spaces before and after the text and the text inbetween there would never be more than one space you could do a global using wildcards (something I've learned on this site before, thanks to Tony Jollans).
Ctrl + H to begin your global.
Click on More to bring up entire Find and Replace menu.
Click on Use Wildcards
Type two spaces in Find
After the two spaces type {1,} (those braces are above the brackets)
This will remove all groups of spaces as long as there are at least two spaces.
An alternate approach, to strip away leading/trailing spaces at paragraph boundaries without affecting spacing within a paragraph, is to run two Find/Replace procedures - one to replace para markers preceded by spaces with just the para marker, and one to replace para markers followed by spaces with just the para marker. To do this:
. Begin your Find/Replace procedure (eg via Ctrl-H).
. Type a single space followed by '^p' in the Find box
. Type '^p' in the Replace box.
. Execute the process. You may want to do this more than once, until Word reports no replacements.
. Type '^p' followed by in a single space the Find box.
. Execute the process. Again, you may want to do this more than once, until Word reports no replacements.
The same approach can be used for clearing out unwanted spaces before/after tabs (using '^t) and soft returns (using ^l).
A simple way to remove leading and trailing spaces is to centre the lines and then left justify them again ...
Ctrl+a, Ctrl+e, Ctrl+l
(to do it to a complete document)
Enjoy,
Tony
-------------------------------------------------------------------------------------------- We want to help you; help us to do it by reading this: Before you ask a question.
Excel VBA Training and more Help at VBAExpress[
All suggestions are good. I would like to point out however:
1. BenRowe's suggestion would also remove two spaces within the line. So if the text has two leading spaces at the start of a sentence (still not uncommon, although a lot of text uses a single space leading into a sentence), those would be removed. The sentence break would have no spaces.
2. Tony's suggestion removes ALL spaces regardless of count. So if the criteria was explicitly TWO spaces (both leading and trailing), but NOT one space (or three for that matter), then it does not meet the requirement.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.