I need a Grep style in my paragraph styles in InDesign that makes sure that the letter i
cannot stand alone at the end of a line, but will always move to the beginning of the next line. I have a client that makes me do it manually.
-
2Why only "i"? But anyway. Just instruct to Find: (\d+)( )(i) replace: $1~S$3 But I would suggest to use script or regular ctr+f as it will change in every instance not only the ones with GREPed style.– SZCZERZO KŁYCommented Feb 3, 2017 at 8:47
-
2@SZCZERZOKŁY I do it with a/A as well, and sometimes two-letter words. Itty-bitty words at the end of a line can sometimes look untidy, and I completely understand the impulse to bump them down to the beginning of the next line.– Lauren-Clear-Monica-IpsumCommented Feb 3, 2017 at 10:40
-
2@LaurenIpsum I Use a script called "UseMyTypo". It can add nonbreaking space after given letters or words as well as remove extra ones etc.– SZCZERZO KŁYCommented Feb 3, 2017 at 11:44
3 Answers
- Create a character style and set it to "No break".
- Edit your existing paragraph style, go to the GREP Style tab, choose the character style you created above and type
(?<=\s)i\W+
in the "To Text" field. (credits go to @Tobias Kienzler who suggested this)
-
2Although you dont need a separate style for different letters you can use the
(i|a|a,)
syntax to enumerate many options. But good thing about the images, clarified this quote much (even though i had voted and tested this before you got them posted for me to see).– joojaaCommented Feb 3, 2017 at 11:12 -
1Correct, the GREP can be improved to deal with multiple issues at the same time.– lmlmlmCommented Feb 3, 2017 at 11:14
-
2If I understand this right, it could probably also be expanded to handle any single-letter word with something like
\s[A-Za-z]\s
– IMSoPCommented Feb 3, 2017 at 11:19 -
4You can also use
(?<=\s)i\W+
(or(?<=\s)\w\W+
). The lookbehind(?<=
makes sure the preceding whitespace remains breakable, otherwise your GREP-style might pull the previous syllable down, too. And\W+
means at least one non-word character, which takes care of punctuation as well. Commented Feb 3, 2017 at 11:50 -
2Hopefully the OP is following these comments and can choose whichever string works best with their document. I am definitely adding this to my own collection of Grep strings. Quite useful comments thanks! :)– lmlmlmCommented Feb 3, 2017 at 13:15
First make a no break character style like in Lucian's asnwer, then try this Grep style in your paragraph style. It worked for me. (?<=[!\?\.]\s)[^\s]{1,3}\s
-
-
-
I took the liberty to clarify that a little. Be aware that because of up/downvotes, answers aren't always displayed in the same order. If you want to know more about the Stack Exchange model and specifically about this site, have a look at the tour and the help center. Oh, and welcome! :D– VincentCommented Aug 23, 2018 at 14:32
This solution works great: (?<=\s)\w{1,3}\W+
only that it won't work for when more than one 1-3 letter words are next to each other, in that case it will skip every other word.
I propose to add a second grep style to account for this (?<=\s)\w{1,3}\W+\w{1,3}\W+
and can keep going to find 3,4,5.. 1-3 letter words together. There is probably a smarter DRY solution to that, but I'm not smart.