@Eparch - now updated. If you test, please add some feedback here about whether it’s working for you. Thanks!
Very thorough explanation. Works great.
I’ve followed these steps and it works fine for the most part. Except all of the punctuation just before the closing quotation mark is changed to $1. Every period, question mark, comma, exclamation point, etc gets changed. Is there a setting I can add to stop the macro from doing this? It’s quite a job going back through hundreds of paragraphs to fix this individually. I believe it has to do with the difference between American English and Britsh English.
I have to amend my earlier comment, since somethin seems to have changed. I now have the same problem as @DragonDreads - it replaces the element before the end quote with a $1, which negates the value of the macro. It’s frankly a lot easier to do all this in Word, and then transpose to LO.
OK, I’m going to answer my own question. It’s a feature I’d never noticed until now.
FIRST, make sure that the replacement of smart quotes is active in your autocorrect settings: Format > Autocorrect > Autocorrect Options…
SECOND, highlight the text that you want to apply your autocorrect options to (including and up to CTRL+A for the entire document.
FINALLY, use Format > Autocorrect > Apply to cause autocorrect to go through and apply it’s autocorrect settings to the selected text.
This is a great feature!
This solution will NOT work if the paragraphs have a “style” other than “Default” applied to them. In my experimenting, this ONLY works if para is set to “Default”. Any idea how to get this solution also to work with “styled” (Text Body, Quotations, Heading 1, etc.) paragraphs? Would be great!
The UI, in specific the menu structure, was modernised recently. Starting with V5.1.y (I think) the feature described was moved to > ‘Tools’ > ‘AutoCorrect’ > ‘Apply’.
Sadly, the limitation in my comment above persists into 5.0.x, anyway: text must have
Default Style applied; it won’t work if, e.g.
Text Body is the style. It also incorrectly applies the typopgraphic-quotes, and then alters the style of the text anyway! The “macro” solution remains more reliable in my testing.
Save your document, turn of auto-save. Save it as a specially named document.
Open your find and replace.
FIND ." and replace with a period and a curly end quote.
Check your document thoroughly for proper replacements. If all is good so far, save it.
Do this with ," and !" and ?" and any other ending punctuation or marks used, such as ellipses, dashes, or n- m-dashes, replacing them until you’re confident you’ve gotten all ending quotes done. Check your document thoroughly.
Then replace all the rest of the " with opening curly quotes.
Check your document thoroughly.
I do it for huge and small documents all the time. I edit for a small specialty writing group.
You might as well also replace short dashes (-) followed by an end quote with at least n-dashes (ALT+0150) and a curly quote. As well as the ubiquitous three periods with real ellipses.
Answering my own comment (well, partially)…
Where there are “styles” applied to paragraphs, the “Autocorrect > Apply” solution will not work. However, it is possible to use regex search-replace to speed up this process enormously. The instructions below are based on a very helpful discussion on the OpenOffice forum (do read through to the end, if it’s of interest).
Hit CTRL-H to bring up the search/replace dialog; use the “More Options” drop-down, and select [x] Regular expressions. Paste in the following values:
First, Search for:
Click “Replace All”.
Then, Search for:
Click “Replace All”. Now do a simple search for " (straight double-quote) to see if any have been missed. There shouldn’t be many!
Much simpler: Search for
[space]' and replace with
[space]‘ for opener, then simply change all the rest of the
' marks to closer
’ and that should do it. There might be cases of
[' which need to be catered for (my doc didn’t have any), but the technique used for the double quotes will take care of those.
There must be a way of putting this all into a macro, but I haven’t thought about that yet. So – if preserving paragraph styles is important (it was to me in a 44-page imported and heavily styled document!), then this regex approach will get the job done very, very quickly.
I can’t seem to type these slanted double quotes you have in the replace with fields. And if I copy from the posting here only the straight quotes are pasted into the replace field. So if I do the replace, the smart quotes do not get used.
I also use special formatting at times so replace is the way to go. I’m using LO 4.1 right now. Any ideas how to get the slanted quotes in the example above?
The commenting tool is not available to me and I can’t upvote posts, very strange.
@david solutions work brilliantly when I was under ubuntu, particularly this expression:
However on Mac the above expression is stop working. Not sure why, maybe it has different way of running regex? There is a post related to this.
I posted this and filed a bug, how there is a solution soon.
@shiyuan - now updated - see my answer with the macro/Gist links for updates. Hope that helps!
"Onene” "twonene” "two”:
Not a specific Mac issue, David. I get the same error on v. 220.127.116.11 (x64) on Windows 7 64-bit, without playing with the code either…
Now updated. If you test, please add some feedback here about whether it’s working for you. Thanks!
When I first ran the macro, I got the following error: undo = ThisComponent.UndoManager Basic Runtime Error Property or method not found.
I rem’d that line; ran the program again and there was another undo-related error. I rem’d out that line; same thing happened again. Without the three Undo-related lines, the program ran fine. If someone is worried about undo…I don’t know how to restore that functionality. The macro is a great fix.
Here’s what I finally came up with:
Do the Find & Replace (CTRL+H) > use the “More Options” drop-down, and select [x] Regular expressions. (as suggested above)
In the “Search For” box, type in "<
In the “Replace With” box, type CTRL+0147 (the ASCII number for a curly left quote).
Then click “Replace all”. This should take care of all of your left quote marks.
Go back to CTRL+H, and in the “Search for” box, simply type in ".
In the “Replace with” box, type CTRL+0148 (the ASCII number for a curly right quote).
Click “Replace all,” and all of your curly quotes should be taken care of.
You can do the same thing with single quotes, just replace the " with a ', use CTRL+0145 for a left single, and CTRL+0146 for a right single.
I tried this and it literally replaced the apostrophe with the ASCII code.