Word: Carriage returns, not paragraph returns

August 28, 2012

One of my readers emailed me with a problem they couldn’t figure out. Here’s a summary of the problem:

I’ve been working on a macro to clean up a document converted from PDF. A lot of these conversions place a pilcrow at the end of each line, I guess because Word isn’t sure what else to do with a line break in a PDF.

Part of the macro runs a find and replace that deletes most of the pilcrows but retains them where it recognizes a paragraph. What’s important here, and what I hope you can help with, is that when it makes a new pilcrow (I’m using ^13 in the find & replace), it treats it like a carriage return. The symbol on the screen is definitely a pilcrow—the same, filled-in black pilcrow I’m used to seeing at the end of a paragraph. I went into the xml of the document, and sure enough there was <cr> instead of <p>.

The paragraphs are all set to 12pts after, but none of them are actually displaying that space. The printed version is the same. It’s not a display issue. It’s just that Word is accepting the command to insert a pilcrow, inserting it, but treating it like a carriage return.

I found a solution, which is to search the document for pilcrows, select them, then type a paragraph. But I’d really like to understand what’s happening (and why) with that find and replace. Why is manually typing a paragraph working while find & replace is not?

My first step in trying to solve the problem was to create a new Word document, add a couple of soft line returns and some normal paragraph returns, then do a find/replace on the soft line returns (^l — that’s a lower case ‘L’) replacing them with ^13. Sure enough, the pilcrow looks the same, but the paragraph formatting (paragraph above/below spacing mostly) wasn’t quite right. When I saved the doc as XML, I found ‘cr’ instead of ‘p’ where I’d done this find/replace, just as my worried reader had found.

I know that ^13 is often required when you’re doing a find/replace with wildcards as ^p doesn’t work (or at least, it doesn’t work under most circumstances).

I did the test again, this time replacing ^l (soft line return) with ^p (hard line return), and the paragraph formatting changed to what it should be for each paragraph.

I did a final test. I added in some soft line returns, replaced ^l with ^13, then to see if ^p would work, I replaced ^13 with ^p and it worked! Those pesky carriage returns created from the ^l to ^13 replace changed to hard line returns when I replaced them with ^p.

Now I’m not sure how all this would work in the macro my reader had created, but at least they now have something they know will work.

All this testing was just in the normal Find/Replace dialog — no special settings at all.

Interestingly, Wikipedia says that ‘In ASCII and Unicode, the carriage return is defined as 13′ (http://en.wikipedia.org/wiki/Carriage_return) but says nothing about the code for paragraphs/hard line returns.

[Link last checked August 2012]


  1. Thanks for this Rhonda – coffee is on the way. Cheers Jane

  2. That worried reader was me.

    Thanks so much for the response! It didn’t occur to me to use ^p, but that’s a great idea! I ran some tests, and it worked like a charm. Thank you!

    I also tried combining ^13 and ^10, CR and LF, but that didn’t work. Guess Word is picky about that ^p combo.

    When running the search as part of a macro, I searched for ^13 and and Selection.TypeParagraph each time it was found. It’s a less elegant solution than simply replacing with ^p, but it got the job done in a pinch. Later I went back and changed the code to replace with ^p, and that worked just as well but a lot faster.

    The pilcrow seems to show up in ASCII and Unicode indexes only on occasion and with mixed results. I’ve seen it under ^20 and ^244, but that doesn’t appear to be consistent across all platforms. ^20 is actually a device control character (Data link escape) that can be reassigned if it’s not needed.

    This lead me to another mystery. Replace ^p with ^20 in the F&R dialog, and you get something that looks a lot like a pilcrow but doesn’t appear to have any value in the document or the XML. I can copy and paste the symbol into another Word doc, but I can’t copy it into my web browser to do a search, and it shows up as empty space in notepad. What’s especially strange about these is that they disappear when the file is closed. They leave no trace at all. What are these symbols for?

    ^20 should be the same thing as alt+20 as far as I can tell. Instead it’s just an empty display character with no staying power. This might be a bug in the software. A lot of Google searching has turned up nothing so far.

    ^244 in Word gives the top half of the integration symbol, so that’s out as a numeric value for the pilcrow. ^p is the star of the show.

    The question I’m left with is this: When Word has a symbol for a carriage return (the bent arrow), why is it still using the pilcrow symbol in some cases to represent a CR? And why wouldn’t they design the wildcard search to always distinguish between the two? ^13 in the Find box finds both CRs and pilcrows. But when ^13 is used to replace text, it defaults to a CR. But that CR is displayed as a pilcrow! How confusing! ^p, on the other hand, only finds pilcrows. Yikes!

    In the future, I’ll be much more deliberate about how I’m searching for and replacing any type of line break in a document.

    Thanks again for your help, and this great blog and newsletter!

  3. […] Carriage returns versus paragraph returns — the saga of ^p versus ^13: https://cybertext.wordpress.com/2012/08/28/word-carriage-returns-not-paragraph-returns/ […]

  4. Thank you so very much!!! I had this problem and couldn’t work out what the heck was happening.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: