1

I want to automatically change:

blah blah blah b
blah blah blah

into:

blah blah blah 
b blah blah blah

in the whole document and keep it like that.

I could insert a hard space before each and every single/orphan letter at the end of the line, but it would take lots of time and also, after slightly modifying text, it would shuffle and cause the same problem again.

Is it possible to automatically force those letters to the next line?

Jim K
  • 12,824
  • 2
  • 22
  • 51
spam
  • 1,853
  • 2
  • 13
  • 33
  • Please give an [MCVE](https://stackoverflow.com/help/mcve) of what you are hoping to achieve. Also, this is more appropriate for https://superuser.com as it does not involve programming. See https://stackoverflow.com/help/on-topic. – Jim K Dec 11 '17 at 20:49

1 Answers1

1

Rather than inserting a space before the character, select the space following the character instead. Press Ctrl+Shift+Space to prevent a line break in that location.

insert non-breaking space

The result:

b is wrapped to next line

To do this for all occurrences in the document:

  • Edit -> Find and Replace.
  • Find: ([:space:][:alnum:])[:space:]
  • Replace: $1\u00a0. However, \u syntax does not currently work for replace, so where it says \u00a0, copy and paste a non-breaking space character instead.
  • Enable Other Options -> Regular Expressions.
  • Replace All.

Related: https://ask.libreoffice.org/en/question/134113/how-to-detect-non-breakable-space-when-iterating-document-via-uno/

Jim K
  • 12,824
  • 2
  • 22
  • 51
  • Right, however if I will modify text on the beginning then everything will fall apart. Can I force LibreOffice to manage this issue and not me (as a human)? – spam Dec 15 '17 at 13:30
  • "Can I force LibreOffice to manage this issue." Yes... by adding a non-breaking space character. I'm fairly certain that is the only way (see [here](https://ask.libreoffice.org/en/question/140281/optional-character-properties/) for another way that does not work). "If I will modify text on the beginning then everything will fall apart." If you add another "blah" then it will wrap appropriately. Perhaps you could give another example of a case where it does not work correctly. – Jim K Dec 15 '17 at 13:54
  • Adding a non-breaking space changes the semantics of the document while the question is about formatting. This answer is at best a workaround and is not a reliable solution: remembering to manually run a "replace all" step to get proper formatting should not be required. – Demurgos May 16 '21 at 19:12