

I'm sure most of us have had to deal with this issue. You copy text from one source, such as an email (which is a notorious source for this problem) and paste it into a document only to discover that the lines of text do not fit the width of your margins. So you find yourself going to the end of each line to manually delete the excess return that has magically appeared, in order to have the text reformat itself.
It's a tedious process. But if you're using Word, or any other software program that has similar search/replace features as Word does, you can make the process easier by hunting out the little buggers and deleting them. And if you can handle a little VBA code, you can make the process as simple as a button click.
Allow me to explain...
The Problem
Let's say you receive an email that contains some important text that you need to insert into another document, such as a Word document. As you can see in the image below, when the email arrives...even though the sender typed to the end of the lines and did not hit the return key, but rather let the software wrap the text as needed...it most often still arrives fairly hard coded with returns inserted. You can't see them in the email, but they are there. Notice the space along the right margin. The text didn't fill the width of the email.

So I copy the text to my clipboard by highlighting what I need and hitting Ctrl + C to copy it. I move to a Word document, position my cursor where I want the new text inserted and hit Ctrl + V to paste the text into the file.
But look at the image below. Notice that there's a wide gap along the right. The first two paragraphs of text were already typed on the page, so they fill the margin. But when I paste in the content from the email, it doesn't fill the page properly! What's the problem?

Well, the first issue is that the text may not be of the same font style. Chances are you'll see a little marker at the end of the pasted text. Click it and you'll see options to change the formatting. Choose Match Destination Formatting, assuming that you want this new text to match with the text that was on the page already.

Now we need to see what's stopping the lines from extending to the far right margin. You can turn on your hidden markers in Word by clicking on the Show/Hide icon, as shown below. Or, if you're a keyboardist, just hit Ctrl + Shift + * and that'll toggle the markers on/off just as you could by hitting that icon.

Once the markers appear, notice that you now have paragraph markers at the end of each line within the pasted text! Yup, that's what's stopping your lines from extending as they should. They snuck into the content during the transmission...a time when lots of strange characters can slip into email.
Now you could go through the document manually, deleting each excess return; but there's a better way.
First, take a close look at the document. You'll notice in the first circle, it shows returns at the end of each line. But notice the second circle...there are two paragraph markers (return keystrokes) next to each other. True, they don't actually look like they are next to each other. But if you put your cursor in front of the first paragraph marker at the end of the paragraph and hit your arrow key to the right, you will see that the next position where your cursor will move is to the next paragraph marker...the one that is separating the two paragraphs.

Now the real, professional way to fix this problem would be to not only remove the excess paragraph markers, but apply a style that has extra spacing above each paragraph to separate them. But let's face it, sometimes doing it the right way is too much work. Yes, even though I harp about using styles, I confess that I don't always use them. Sometimes I'm just in a hurry and know the document won't be a major project, so I just apply manual formatting as I go along.
The Fix
Either way, first you have to deal with all those excess returns. To do this manually, you can use the Replace feature in Word. Click Edit > Replace to open the appropriate dialog box.
In the Find what: input box, you need to type the characters that represent the paragraph marker, which in Word is ^p (make sure it's a lowercase p). However, before you can delete all the excess paragraph markers, you need to deal with the double returns protecting the paragraph separations.
So start by tackling those. Enter two paragraph marker characters (^p^p) in the Find input box, as shown below. Now in the Replace with: input box, you can actually insert anything your little heart desires. But a big consideration is that you need to make sure that you don't use any character combinations that might be present in the document in any other location. This is because later you'll replace those goofy characters with two paragraph markers again to replace the paragraph breaks. If you have a string of characters like the ones you use somewhere else in the document, you'll end up with a paragraph break where you don't really want one!
So use a character string that you are sure isn't anywhere in your document. As a default, I always use @#$% (Shift + 2, 3, 4, 5 on the alpha numeric keyboard).

Now click Replace All.
As you can see below, that goofy replacement string now appears in my document and those double returns are gone. That's what we want. We'll get back to those in a bit.

But now that we've protected all the paragraph separations with our character string of unusual characters, we can go right ahead and just delete all the other returns...which are the excess ones that are stopping the lines of text from wrapping properly.
Go back to the Edit > Replace dialog box. But this time, enter just one paragraph marker character (^p) in the Find box and don't put anything in the Replace box. This tells Word to find all the current paragraph markers and replace them with...nothing! In other words, delete them.

Click Replace All.
Now look at the mess we have! All the text is jammed up into one huge paragraph. But fear not! Since we protected the true paragraph separations with that goofy character string in the beginning, we can now easily reverse that action to return the double paragraph markers and thus, return the paragraph breaks.

So back to the Edit > Replace box you go.
This time, enter the character string that you used as your holder for the para breaks. In my case, I'll enter @#$% into the Find box. In the Replace box, I now need to enter two paragraph markers (^p^p).

Click Replace All to run this Find/Replace process.
In the image below, you'll see that the pasted text now fills the page much better because the extra returns are gone, so the text can extend to the end of the right margin. But also, the original paragraph breaks are inserted.
Note that if you were planning to do this correctly and use styles with Space Before, you would have only replaced the holding character string with one paragraph marker. Then you'd select your text and have your paragraph style applied. This would space the paragraphs apart properly without the use of a return between each paragraph. (Using a style with space before (or after, your choice...I prefer before) is the way it really should be done if this was a document that will require more formatting or may have format changes in the future).

Automate the Fix
If you want to make this process even easier, you can record a macro that can be replayed whenever you need to do this again. This is the great benefit of understanding macros...you can save lots of time by recording repetitive moves that you'll need to do again in the future.
To record your macro, before you start the process of running the multiple Edit > Replace procedures, start the macro recorder by clicking Tools > Macro > Record Macro or just double click the REC button that looks like a grayed out square at the bottom/middle of your Word screen. Give the macro a name and then start the process. All your moves will now be recorded. Later you can replay the macro which will move through all these same steps...but it'll happen in an instant!
A tip however, hit Ctrl + Home prior to each search to make sure your cursor is positioned at the beginning of the document. This way the search will always run from the top of the document.
Also, if, by chance, you only need to search on a small portion of your document, you can highlight the area before you run a search and it'll be processed only on the selected text. However, assuming you don't have any special double return formatting within your document other than the normal paragraph breaks, it's not a problem to run the search on previously typed text that would also have double paragraph markers, since they'll just get reformatted as they were. But if you did use styles on the previous text already and aren't using double returns to break paragraph markers, consider what you're about to do carefully. Depending on your style, you might cause yourself problems with a full doc search. But also remember, you can always click the Undo button to undo what you did that you didn't want to do!
And for those of you too lazy to record your own macro<grin>, feel free to swipe my code below, which will run the above process we just did manually (and does include the Ctrl + Home keystrokes, as I recommended).
If you don't know what to do with the code below to make it work, see this article: Sharing Macros. That article will also show you how to put the macro on a menu so you can easily click to run it over when needed. If you prefer to put it on a toolbar, see this article: Customized Toolbars and Menus.
Sub DeleteExcessReturns() Selection.HomeKey Unit:=wdStory Selection.Find.ClearFormatting With Selection.Find .Text = "^p^p" .Replacement.Text = "@#$%" .Forward = True .Wrap = wdFindContinue .Format = False .MatchCase = False .MatchWholeWord = False .MatchWildcards = False .MatchSoundsLike = False .MatchAllWordForms = False End With Selection.Find.Execute Replace:=wdReplaceAll Selection.HomeKey Unit:=wdStory Selection.Find.ClearFormatting Selection.Find.Replacement.ClearFormatting With Selection.Find .Text = "^p" .Replacement.Text = "" .Forward = True .Wrap = wdFindContinue .Format = False .MatchCase = False .MatchWholeWord = False .MatchWildcards = False .MatchSoundsLike = False .MatchAllWordForms = False End With Selection.Find.Execute Replace:=wdReplaceAll
Selection.HomeKey Unit:=wdStory Selection.Find.ClearFormatting Selection.Find.Replacement.ClearFormatting With Selection.Find .Text = "@#$%" .Replacement.Text = "^p^p" .Forward = True .Wrap = wdFindContinue .Format = False .MatchCase = False .MatchWholeWord = False .MatchWildcards = False .MatchSoundsLike = False .MatchAllWordForms = False End With Selection.Find.Execute Replace:=wdReplaceAll End Sub

|