How to Find and Replace Paragraph Marks Around Graphics in Word
Question details
The user needs to remove paragraph marks that are located immediately before and after an inline graphic in a document, without deleting or displacing the graphic itself.

- Product
- Microsoft Word
- Device & OS
- not provided
- Scenario
- Cleaning up document formatting where inline images are surrounded by unnecessary hard returns or paragraph breaks.
- Observed behavior
- Unwanted paragraph marks exist before and after the graphics, and standard find and replace operations risk deleting the images entirely.
Before running a wildcard find and replace operation, it is highly recommended to save a copy of your document to prevent accidental formatting loss if the wildcard syntax matches unintended text.
Use Wildcards in the Find and Replace Dialog
By enabling wildcards in Microsoft Word, you can use specific codes to target paragraph marks and group the graphic so it can be preserved during the replacement.
When wildcards are enabled in Word, standard codes like ^p for paragraph marks do not work. Instead, you must use the ANSI character code ^13 for a carriage return. Using parentheses allows you to group the graphic and reference it in the replace field.
Press Ctrl+H on your keyboard to open the Find and Replace dialog box. Click the 'More >>' button to expand the advanced search options.
Check the box labeled 'Use wildcards' in the Search Options section.
In the 'Find what' field, type ^13(/)^13. In this string, ^13 represents the paragraph marks before and after, and (/) captures the graphic between them.
In the 'Replace with' field, type \1. This tells Word to replace the entire matched string (the graphic and the surrounding paragraph marks) with only the contents of the first set of parentheses, which is the graphic itself.
Click 'Find Next' to test the first instance, and if it works correctly, click 'Replace All' to apply the formatting cleanup to the entire document.

Edit and Format Documents Seamlessly with WPS Writer
WPS Office provides a highly compatible Writer application that supports advanced Find and Replace functions, including complex wildcards, just like Microsoft Word. You can easily clean up your document formatting efficiently.
- 1. Open your Document in WPS: Launch WPS Writer and open the document containing the graphics you want to format.
- 2. Access Advanced Find and Replace: Press Ctrl+H to open the Find and Replace dialog, click 'Options', and check 'Use wildcards'.
- 3. Input the Wildcard Syntax: Type ^13(/)^13 in 'Find what' and \1 in 'Replace with'.
- 4. Replace All: Click 'Replace All' to instantly remove the extra paragraph marks around your graphics while keeping the images perfectly in place.

Frequently Asked Questions
Why does using ^p not work when wildcards are enabled?
When the 'Use wildcards' option is turned on, Microsoft Word does not recognize the standard ^p code for a paragraph mark in the 'Find what' box. You must use the ANSI character code for a carriage return instead, which is ^13.
Can I replace the paragraph marks with a space instead of removing them completely?
Yes. In the 'Replace with' box, type \1 followed by a single space (or a space then \1, depending on where you want the space). This will preserve your graphic and add the space.
What does the \1 mean in the Replace with field?
The \1 is a backreference that refers to the first grouped expression in your 'Find what' box, which is enclosed in parentheses (). In this scenario, it tells the program to put the graphic back in place while discarding the elements outside the parentheses.
How do I find a graphic without using wildcards?
If you are using a standard search without wildcards, you can search for inline graphics by typing ^g in the 'Find what' field of the Find and Replace dialog.




