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

Ask Your Question

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

asked 2021-02-17 12:49:26 +0200

Bmblbzzz gravatar image

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?


edit retag flag offensive 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.

gabix gravatar imagegabix ( 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.

Bmblbzzz gravatar imageBmblbzzz ( 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.

gabix gravatar imagegabix ( 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.

Bmblbzzz gravatar imageBmblbzzz ( 2021-02-17 15:23:21 +0200 )edit

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.

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

1 Answer

Sort by » oldest newest most voted

answered 2021-02-17 13:10:32 +0200

Przemo gravatar image

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.

edit flag offensive delete link more


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

Bmblbzzz gravatar imageBmblbzzz ( 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 (x86); OS: Windows 6.1.

Windows users can use Alt+0160.

LeroyG gravatar imageLeroyG ( 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.

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

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

Not with me.

LeroyG gravatar imageLeroyG ( 2021-02-17 15:55:54 +0200 )edit
Login/Signup to Answer

Question Tools

1 follower


Asked: 2021-02-17 12:49:26 +0200

Seen: 83 times

Last updated: Feb 17