Prevent Writer from splitting strings (after a hyphen for example)

Hello,

is there an option in Writer to prevent it from splitting long strings of characters?

I have a document with many strings that are several hundreds of characters, and Writer is splitting them if it sees a hyphen in the string. So sometimes the long string is cut after a couple of characters and continues on the next line. I would like it very much if I can tell Writer to always fill each line completely without splitting the long strings.

I know about Ctrl-shift-hyphen, but that changes the character to grey background (not a solution for me).

EDIT: This option should never split a string, not even after a space or any other character.

Thanks in advance.

There is no automatic solution unless you slightly modify the string. Inside the strings replace all standard hyphens by U+2011 NON-BREAKING HYPHEN (this is the same as Ctrl+Shift+-) and all standard spaces by U+00A0 NO-BREAK SPACE (same as Ctrl+Shift+ ).

You may find that no-break space is wider than ordinary space in certain fonts. Unfortunately you can’t use other spaces defined starting at U+2000 because these spaces (with various widths) have not the no-break property.

Since these no-break characters are considered formatting marks, the UI gives them the same backgrounds as fields. This background doesn’t print, so it is harmless, just a reminder you have a “special” character. In case, you handle your document only on screen and find this background disturbing, you can disable it with View>Field Shadings. Note it is generally a bad idea.

If your string contains non alphanumerical characters besides hyphen, like punctuation, Insert>Formatting Marks>No-width No Break after the punctuation. For bulk insertion, this is U+2060 WORD JOINER.

Another approach could be to systematically insert U+2060 after every character of the string, except the last one so that you don’t think about which character should be “marked” or not. This can be done with Find & Replace.

A final note: your strings have a special meaning in your document (obviously they are not human meaningful words). It would be a good idea to mark up them with a dedicated character style in which language is set to None in order to silence spell-checking. Unfortunately, it is not possible to give a no-break property through a style.

3 Likes

Maybe \W.

Source: Regular Expressions - ICU Documentation

That’s right, but you can turn it off.
Field Shadings

1 Like

Thanks for replying.
But it still splits after a question mark or after a space. Is there no way to tell Writer to never split any word, unless at the end of the line?

It also splits after a pipe or after a plus sign or a forward slash…

I’ve searched the internet, and the options in LibreOffice, but I can’t find a way to disable this splitting of strings.

Go to Menü Insert → Formatting Mark

2 Likes

A solution, thanks PKG.
I mapped it to F12, so its not a lot of work.