Start learning with our library of video tutorials taught by experts. Get started
Viewed by members. in countries. members currently watching.
With its ability to find and replace character patterns in documents, GREP helps designers and editors work quickly and efficiently. Over the course of InDesign: 10 Things to Know About GREP, David Blatner demonstrates how to use GREP codes to improve workflow. He teaches GREP search techniques using patterns of numbers or letters or strings of words. David even shows how to use text patterns within a document. Exercise files accompany the course.
I'm going to zoom into the lower left corner of this page and I can see that inside these paragraphs, I have numbers and I want to apply special formatting to just the numbers. Now, I know that I could use the Find/ Change dialog box to type in special GREP codes and apply formatting using those codes, but the problem is what happens if my text gets changed? If I add a number somewhere? Well, that's a big problem because I would have to run the Find/ Change query over again. Kind of annoying. So wouldn't it be cool if there were some way to apply formatting using GREP codes that would happen automatically in the background? Just add a number and boom, it would change. Well there is and it's called GREP Styles. And it's one of my favorite features in InDesign CS4. Let me show you how it works.
You can apply GREP Style to a single paragraph if you want to, just by selecting that paragraph or any part of that paragraph, coming up to the control panel fly-out menu and choosing GREP Styles. The problem with doing it this way is that it affects just that one paragraph. That's kind of annoying because I wanted to change my entire document not one paragraph. So I never use this I just wanted to show you that it is possible, you can change a single paragraph. I'll cancel out of that and instead I'm going to go to the Paragraph Styles panel. This makes a lot more sense. Edit the Paragraph Style that is applied to all of these paragraphs.
In this case it's Body, so I'm going to right-click on Body choose Edit and then move over here to the GREP Style pane of the Paragraph Style Options dialog box. Now this user interface is a little bit clunky, it's not very intuitive in my opinion, but once you see how to do it once it's totally obvious. You will get it right away. Let me show you. First click New GREP Style then type the GREP code that you want to search for inside that your text field. Well, this is a problem. It doesn't look like there is any kind of editable field here, right? Well, there is. How do you get it editable? You just click on it, just click once and boom.
Now it's editable and we can see that this GREP code is backslash d (\d), which is the code for a digit, and then the plus symbol, which means one or more. So this is the code for one or more numbers, which is in fact exactly what I was aiming for. So I don't even need to edit this default GREP code at all. Now I need to choose a character style from the Apply Style pop-up menu here and once again it doesn't look like there is a pop-up menu, until you click on it, then it activates it. So I'll go down here and I'll see that I don't have one that I want to apply yet so I'll choose New Character Style. And I'm going to say this is my number style and why don't I go ahead and change the color to something else? Maybe magenta and maybe I'll change it somehow like make a Proportional Oldstyle.
So it's going to be a different color and it's going to be Oldstyle. Because I have the Preview checkbox turned on here, I'll move the dialog box over a little bit, you can see that all the numbers in all of these paragraphs get changed to magenta and the Oldstyle numerals, pretty cool. I'm going to click OK here and I'm going to scroll over, pan over here to this paragraph up at the upper right corner and I can see that there are fractions in here. That's interesting. Fractions are going to be different. Fractions can be a real pain in InDesign, but there is the open type fraction formatting that you can apply but it's just really annoying because you can't apply the fraction formatting to the entire paragraph because all of your punctuation will go berserk. So, instead you only want to apply it to things that look like a fraction. Well I said looks like a fraction, right that sounds like I'm defining a pattern, things that look like a fraction. Let's go ahead and see how it's done.
I will double-click on Body because that's actually what's still selected here and I'm going to go the GREP Style pane here and click New GREP Style and this time I'm going to apply a fraction style to anything that looks like a fraction. \d, plus because I want it to be one or more numbers, followed by a slash, just a regular slash on the keyboard followed by \d+. There we go. That's what a fraction looks like. One or more numbers followed by slash, followed by one or more numbers and I'm going to apply a special character style to it, New Character Style. I don't know why the document reflowed in the background there that's kind of weird probably a little redraw glitch there, sometimes InDesign does that. That's okay.
I'm going to come to the OpenType Features and I'm going to turn on Fractions. And in fact, I'll call this my fraction style and I might as well also change the color because I wanted that magenta colored numbers I'll make this magenta as well. Click OK, click OK and then zoom back up here and we can see, there we go. Now I automatically get true fractions because fractions are inside this font. But remember it's not just the text that's already there. If I later go in here and edit the text perhaps add a new fraction, then it will update automatically. For example, I'll delete that 1 and you can see that now it's not a true fraction anymore, but if I change it to a 7 it becomes a true fraction. If I come over here and say 22, I get the regular numeral character formatting. slash and then 7. As soon as I type that 7, InDesign says oh, well that matches my pattern, one or more digits followed by slash followed by another one or more digits. Looks like a fraction; let's apply the fraction style to it.
So GREP Styles are very, very powerful. Let me show you one more example of how I use GREP Styles, I use this all the time. Let's jump over here to page 6 and I'm going to zoom in here to this text. Bliss No. 5, my company name. So I select it and press Command+4 or Ctrl+4 on Windows. You can see that even here because we assigned numbers in this Paragraph Style, it's showing up here as well. But I want to apply special formatting to this whole company name, Bliss No. 5.
How do I do it? I'll go back to my Body text, double-click on it to edit it, hit GREP Style, make a New GREP Style, and this time I want a special GREP Style that targets just my company name and it's going to be Bliss No. 5. there is nothing special about this. It's literally just that text. Anytime that it finds Bliss No. 5, there is no special codes. Whenever it finds this text, it should apply my special New Character Style called my company style and once again we'll go and change this to -- how about something, how about Myriad Pro Semibold? Let's do a different color now, how about blue? And that looks pretty good.
Well, one more thing that I often do here is in Basic Character Formats, I'll turn on No Break. So my company name will never break across two lines. It won't hyphenate and it won't break across lines. It will always stay together. I like that. Click OK, click OK and we can see that it changed the formatting and No Break was automatically applied to it. So it will never break across multiple lines. I love GREP Styles. It's an incredibly efficient way to apply formatting to any pattern of text inside of a paragraph.
There are currently no FAQs about InDesign: 10 Things to Know About GREP.
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.
Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.