# selectively clear direct formatting [closed]

I have to insert text from MS-Word documents into Writer that have a lot of direct formatting (fonts, font sizes etc.). However, superscript and subscript have here a semantic meaning (formulars, units) and need to be preserved.

When I do Format > Clear direct formatting it removes all formatting and I have to do a lot manual work restoring the superscript/subscript formatting. Is there a more efficient way?

edit retag reopen merge delete

### Closed for the following reason the question is answered, right answer was accepted by Alex Kemp close date 2016-02-19 06:10:11.654885

Are you sure, that there is not a character style applied?

( 2014-02-02 02:20:57 +0200 )edit

Sort by » oldest newest most voted

EDIT

There is a much easier way to achieve this, answered by @pierre-yves-samyn: https://ask.libreoffice.org/en/questi...

I have used the following workaround:

1. Search with regular expressions for (.*) with desired style, e.g for bold (see formatting button on lower right corner).

2. Replace it with e.g <b>$1</b> 3. Repeat with all other formatting you need, e.g italics and super- or subscript. 4. Select all, Clear all Formatting. Now your document looks something like "This <b> was bold,</b>, this was <i>italic</i>." 5. Do it the other way around. Search for <b>([^<]*)</b> and replace it with$1 and let the replace box have the desired formatting.

And you are done.

BTW, formatting applies to "search for" or "replace with" boxes, depending on which one is selected. So does the "No formatting" button.

more

Thank you for your reply! Actually I will test another versions, like EuroOffice or something. In OO I was able to assign a shortcut to this function, and have it at one click. And so my colleagues. Compare this to your kind recipe. Looks like someone manages LO development in the way to make it less, and less usable for an average user.

( 2014-02-11 10:00:53 +0200 )edit

@frankaen, true. But hey, why not write an extension?

( 2014-03-20 00:47:08 +0200 )edit

Very confusing mistake in the explanation at step 2: you need to use $0, not$1 or the output will be empty. The method is very effective though!

( 2014-11-01 19:09:48 +0200 )edit

@darioshanghai, no not a mistake at all. $0 returns the whole match, while$1 is just the first group, which means anything inside first pair of parenthesis (). So if your search is (.*) not .*, then it will work just fine. Although for this case using .* and \$0 would be 2 characters shorter.

( 2016-08-13 19:22:14 +0200 )edit

Interesting that in your case Clear Direct Formatting works, because I have some characters formatted more than bold, italic and so on, and CDF removes only this simple formatting, but not advanced, like changed intercharacter space, underline, colour.

more