Small time-saving computer shortcuts are great news for at least two reasons. First of all, as we research and write week after week the seconds saved with each shortcut add up to substantial gains. Secondly, it is helpful for maintaining concentration if we can minimise unnecessary clicks and key-presses. So in this post I want to share one of my favourite go-to Microsoft Word macros that tidies up messy pasted text instantly.

Strip line breaks from selected text

One problem inherent in pasting passages of any length from a PDF into Word is that the text does not run on from line to line, and you end up with the original line breaks and end-of-line hyphens preserved in the pasted version. It can be tedious systematically to delete the line breaks and hyphens one by one, and if you are using multiple quotations from a source text the time taken to tidy each one up can lumber you with much unnecessary and distracting work. This little macro deletes all the line breaks in any chunk of selected text.

To read all the research hacks posted to date, please click here.

It also automatically strips out all the line-break hyphens that often appear in pasted text. So, for example, the word “resolution” here:

Is corrected by the macro to this:

The macro does this while leaving the legitimate hyphens intact.

Add a keyboard shortcut for the macro (see the instructions in this post), and you will be tidying up pasted paragraphs in a flash.

Sub DeleteAllLineBreaksInSelection()

    Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting
    With Selection.Find
        .Text = "^p"
        .Replacement.Text = " "
        .Forward = True
        .Wrap = wdFindStop
        .Format = False
        .MatchCase = False
        .MatchWholeWord = False
        .MatchKashida = False
        .MatchDiacritics = False
        .MatchAlefHamza = False
        .MatchControl = False
        .MatchByte = False
        .CorrectHangulEndings = False
        .HanjaPhoneticHangul = False
        .MatchAllWordForms = False
        .MatchSoundsLike = False
        .MatchWildcards = False
        .MatchFuzzy = False
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
    'start
    With Selection.Find
        .Text = "- "
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindStop
        .Format = False
        .MatchCase = False
        .MatchWholeWord = False
        .MatchKashida = False
        .MatchDiacritics = False
        .MatchAlefHamza = False
        .MatchControl = False
        .MatchByte = False
        .CorrectHangulEndings = False
        .HanjaPhoneticHangul = False
        .MatchAllWordForms = False
        .MatchSoundsLike = False
        .MatchWildcards = False
        .MatchFuzzy = False
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
    Application.Selection.EndOf
   Selection.TypeParagraph
    'finish
End Sub

 

If you find this useful, you may also be interested in my macros to highlight all quotations in a document and highlight all punctuation in a document.

LIKE THIS POST?
. Sign up for my blog updates and never miss a post.

* indicates required