28

Using Microsoft Word 2007, is it possible to replace the newline character (\n) with some other character?

What about vice versa? (That is replace a character with the newline character).

1
  • In word new line character is written as ^p.
    – user127379
    Apr 9, 2012 at 16:18

5 Answers 5

25

Go to Find (Ctrl+F) -> tab Replace -> click More... -> Special -> End of paragraph. The symbol is ^p. You can use it in both directions. I have MS Office 2007, but it should work in older versions too.

1
  • 1
    Does not work in Word 2019. There is no "End of paragraph", and using ^p results in error ^p is not a valid special character
    – cowlinator
    Dec 6, 2021 at 4:17
10

Background info

According to this answer to a question on StackOverflow, Word versions '97-2013 used regular regexp syntax (pun intended). Unfortunately, it seems that Microsoft has since ditched regexp in favor of its own "Wildcard" syntax. I'm running Word 2016, and the only alternative to the basic literal searching (with a few special character escapes) is "Wildcard" matching, which is... basically an annoyingly limited regexp.

The answer (for those running later versions of Word)

If you're using Word's version of regular expression (regex/regexp) syntax (enabled by checking the box labeled "Use wildcards" in the Find and Replace dialog*), then newlines are matched by ^13 (which I suppose is equivalent to ^p, "Paragraph mark", which Find/Replace only accepts when "Use wildcards" is not selected. Go figure!).

Neither ^l ("Manual line break"), ^n ("Column break"), will catch regular old newlines (like, the kind you enter when you press, well, the ENTER key.

I do believe that section breaks are matched by m ("Page/Section break"), however.

NB: These Replace options are not accessible via the Find interface in the Navigation sidebar that pops up when you hit CTRL+F. As user3251498 has pointed out, you must hit CTRL + H to bring up the Find and Replace dialog.

5
  • 2
    ^13 worked for me on Word 2016, whereas all of ^p, ^n and ^l failed. After I'd replaced the line-breaks, when I copypasted the text into a table in Word, the line-breaks weren't recognised but they were recognised in Excel 2016.
    – Jam
    Nov 29, 2017 at 18:23
  • 1
    @Jam Why not just select the text and convert it into a table, rather than pasting it into a pre-existing one? You might also want to check what kinds of separator Word recognizes as the "new row" separator for tables. It may not be the paragraph break. (I'm not sure.)
    – Stan
    Dec 11, 2017 at 18:10
  • Well, that's a pain, but at least I know now. Thanks Apr 18, 2019 at 20:14
  • Damn, ^l worked perfectly whereas everything else failed, thanks!
    – Big_Chair
    May 24, 2019 at 8:47
  • This is so so so dumb. "This" meaning why the heck do you change to ^13?? Thank you @ksoo!
    – Unrelated
    Jan 21, 2022 at 21:04
2

Paragraph mark ( Paragraph mark )

^p (doesn't work in the Find what box when the Use wildcards option is turned on), or use ^13

1
  • Brilliant! ^13 with wildcards turned on works perfectly!
    – CJ Dennis
    Sep 26, 2019 at 23:14
0

Press Ctrl+H. In Find, type \n and type the desired character in Replace. Be sure to check the Regular expression check box.

That is it.

1
  • 5
    Wrong answer. Word doesn't recognize \n. Jul 3, 2016 at 5:48
0

So took me some time to figure this out.

Press ctrl + H keys together and you open a find and replace tab.

For searching a '\n' character or what enter key does you need to type ^l This makes it look for every place you have hit the enter key.

Also for some reason Microsoft word does not understand \n.

You must log in to answer this question.