Is there a way to exclude some styles from autocorrect?
Typical use case:
I use Writer for documents with code blocks. I like some autocorrect features, as "smart quotes", dashes instead of hyphens, and captial letters after dots. But, for obvious reasons, I want to avoid such replacements in code.
Thus, I use "Text Body" style for my main text and "Code Listings" style for my code blocks. And I want to achieve this desired result:
As you can see, replacements were applied for "Text Body" style, whereas "Code Listing" style preserved exactly as I typed, without any autocorrect changes.
Is there any way to achieve this?
Thanks, John.
Update
Well, it seems, there is no option for it.
https://bugs.documentfoundation.org/sho ... i?id=77568
Anyway, any ideas are welcome.
Exclude some styles (namely, code blocks) from autocorrect
Exclude some styles (namely, code blocks) from autocorrect
LibreOffice 5.2.7 on Windows 7
- Hagar Delest
- Moderator
- Posts: 32668
- Joined: Sun Oct 07, 2007 9:07 pm
- Location: France
Re: Exclude some styles (namely, code blocks) from autocorre
Have you set the language to [None] in the font tab of the paragraph style "Code Listing"?
LibreOffice 7.6.2.1 on Xubuntu 23.10 and 7.6.4.1 portable on Windows 10
Re: Exclude some styles (namely, code blocks) from autocorre
Interesting. I changed language to [None], but it doesn't helped, because right after I typed something, the language was automatically detected as US English.Hagar Delest wrote:Have you set the language to [None] in the font tab of the paragraph style "Code Listing"?
Then, I enabled "Ignore system input language" in Options. And now it's a bit fixed, but not completely. The quotes stay "dumb" (straight, not curly, good), but hyphens still changed to n-dashes, and first letter after the dot still changed to capital. So, at this moment of time, playing with languages fixed only the quotes.
LibreOffice 5.2.7 on Windows 7
Re: Exclude some styles (namely, code blocks) from autocorre
To my knowledge, there is no way for styles to interact with the autocorrect behavior.
Styles may disable spellcheck by setting the language to "none". This is often done for code styles, since there's no sense in checking the spelling there.
Quotes interact (indirectly) because the exact behavior of the quotes depends on the language being used; if the language is "none", it disables the automatic change from straight to curly quotes.
Styles may disable spellcheck by setting the language to "none". This is often done for code styles, since there's no sense in checking the spelling there.
Quotes interact (indirectly) because the exact behavior of the quotes depends on the language being used; if the language is "none", it disables the automatic change from straight to curly quotes.
AOO4/LO5 • Linux • Fedora 23
Re: Exclude some styles (namely, code blocks) from autocorre
By the way, dashes also depends on languages. In some languages, it is common to use n-dashes, whereas in another languages the m-dashes are used. Writer, however, always inserts n-dashes if language is set-upped to [None]. So, Writer is a bit inconsistent between quotes and dashes. It should be more correct to use the same logic as for quotes - the hyphens should not be changed to anything.acknak wrote:Quotes interact (indirectly) because the exact behavior of the quotes depends on the language being used.
LibreOffice 5.2.7 on Windows 7
- Hagar Delest
- Moderator
- Posts: 32668
- Joined: Sun Oct 07, 2007 9:07 pm
- Location: France
Re: Exclude some styles (namely, code blocks) from autocorre
I did some checks before posting and the dashes are not replaced if the language is set to [None].john1320 wrote:The quotes stay "dumb" (straight, not curly, good), but hyphens still changed to n-dashes, and first letter after the dot still changed to capital. So, at this moment of time, playing with languages fixed only the quotes.
Agreed. Both should have the same behavior, I also discovered that with by investigating your problem. It is the same with the ordinal numbers (1st, ...), it changes it whatever the language.john1320 wrote:Writer, however, always inserts n-dashes if language is set-upped to [None]. So, Writer is a bit inconsistent between quotes and dashes.
But all that should be language sensitive IMHO (like the dashes).
LibreOffice 7.6.2.1 on Xubuntu 23.10 and 7.6.4.1 portable on Windows 10
Re: Exclude some styles (namely, code blocks) from autocorre
Strange, doesn't work for me. Probably I should test more or maybe it is some difference between Open and Libre Office.Hagar Delest wrote:I did some checks before posting and the dashes are not replaced if the language is set to [None].
LibreOffice 5.2.7 on Windows 7