Copy link to clipboard
Copied
Is there an easy way to search for 2 or more words/characters and keep together on same line so they don't break?
e.g. Dr name, Mrs name, 10 September, pp. 1-10
I have a long list of words that I don't want to break and have to do manual searches.
[Just for comment]
\b(Dr|Mr|Ms|Mrs|Prof)\.?\K\h
(^/) The Jedi
Copy link to clipboard
Copied
Create a character style with the no break property set and then in the Find/Change Dialog in the Grep section search for something like
Find What : Dr\s\w+
Change Format: Apply your created character style.
You can do so for each entry you have.
-Manan
Copy link to clipboard
Copied
There are a lot of permutations of salutations, what if one is write as Dr and another as Dr.
I usually do a find and replace for the space after the word for example
Find (after the last \K is a space)
\b(Dr.?|Mr.?|Ms.?|Mrs.?|Prof.?)\K
Replace with
~S
You could also replace this No Break character style
Replace with - leave blank
And in the change to style change it to No Break character style
You can also use this in a GREP style for the paragraph - again using a No Break style (as @Manan Joshi suggested - just tacking on to the idea.
For the months
Date format what you describe 10 September
\b\d{1,2}\K (?=(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\b)
I choose the shortened version in case you have dates like 10 Sep
That GREP will only find the space between the words.
My personal preference is to replace the space with a non-breaking space.
That way if you we were to say add a Bold style to one of the names or the dates - you might inadvertently remove the no break style.
A non-breaking space as a character is a bit better - but manual find and replace.
The Style is a great option but it can inadvertently add the style to words you didn't mean to add it to.
Each way has it's caveats.
I prefer the non-breaking space method.
Copy link to clipboard
Copied
[Just for comment]
\b(Dr|Mr|Ms|Mrs|Prof)\.?\K\h
(^/) The Jedi
Copy link to clipboard
Copied
So strange - it didn't work for me earlier - hence my approach - but it's working now.
Need more coffee... thank you for this, I'm a bit confused why it works sometimes and not others... but seems to be ok now.