We will be migrating from Ask to Discourse on the first week of August, read the details here

How to insert non-breaking spaces using 'replace all'?

Editing long documents with many people's names, I want to replace the spaces after Mr, Ms, etc, with non-breaking spaces, in order to avoid the situation where the title is at the end of one line and the name on the next: Mr Smith

I'm used to MS Word, where I can do this quickly and simply using 'replace all'. But LibreOffice (which I've been using about a month) doesn't seem to support non-breaking spaces in the replace all function. Finding them manually in a document of several hundred pages, when there are several on each page, is a drag and a time-killer! Is there a way to do this automatically or quickly?

Thanks!

edit retag close merge delete

LibreOffice does support non-breaking spaces both in the Find field and in the Replace field. What did you try exactly?

Also, try AltSearch.

( 2021-02-17 14:08:07 +0200 )edit

I was trying to find something equivalent to the "caret characters" in MS Word, where you can type ^- into the search and replace box and it is interpreted as a non-breaking space. So "find: Mr " and "replace: Mr^-" I found a list of "regular expressions" for LibreOffice but no non-breaking space in there. Found mention of "&nbsp" somewhere but that didn't work.

( 2021-02-17 14:34:17 +0200 )edit

There is no need to follow Microsoft's stupidities. Just enter a plain non-breaking space. It works without any regular expressions or similar things.

( 2021-02-17 15:02:03 +0200 )edit

Well that's what I tried to do initially. But it doesn't work – except by copy paste, as Przemo suggested. There's no way, that I have found, of entering a non-breaking space directly into the find and/or replace box.

( 2021-02-17 15:23:21 +0200 )edit
1

A non-breaking space can be entered directly using your operating system/graphic environment conventional method, for example, by Compose <space> <space> in Linux. Or right-click, select Special Character and pick a non-breaking space in the character map.

( 2021-02-17 15:38:05 +0200 )edit

Sort by » oldest newest most voted

You can't type it directly in the Find & Replace window with Ctrl-Shift-Space, but you can type "Mr " in the text, copy and paste in the Find & Replace window. Copying the non-breaking space on it's own doesn't work - that looks like a bug.

more

Thank you! Just tried that and it works. Don't know why I didn't think of it myself...

( 2021-02-17 14:00:54 +0200 )edit

I can copy a no-break space (Unicode U+00A0) and paste it in the Replace: field.

Tested with LibreOffice 6.4.7.2/7.0.4.2/7.1.0.3 (x86); OS: Windows 6.1.

Windows users can use Alt+0160.

( 2021-02-17 14:28:57 +0200 )edit

Thank you! This works too (the Alt+0160). Bizarrely, when entered directly into the document itself it puts a non-breaking space after the character following the cursor!? But that's not a bid deal and in the find and replace box works fine.

( 2021-02-17 15:29:40 +0200 )edit

Alt+0160 puts a non-breaking space after the character following the cursor

Not with me.

( 2021-02-17 15:55:54 +0200 )edit