Start learning with our library of video tutorials taught by experts. Get started

InDesign: 10 Things to Know About GREP
Illustration by John Hersey

3. Using GREP for styles


From:

InDesign: 10 Things to Know About GREP

with David Blatner

Video: 3. Using GREP for styles

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.

Watch this entire course now—plus get access to every course in the library. Each course includes high-quality videos taught by expert instructors.

Become a member
please wait ...
InDesign: 10 Things to Know About GREP
1h 8m Intermediate Apr 30, 2009

Viewers: in countries Watching now:

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.

Topics include:
  • Using pre-built find/change expressions
  • Reordering names in an exported list from a database
  • Working with GREP and fonts
  • Establishing character formats with GREP style
  • Using escape characters to customize code
  • Accessing the fly-out menus to specify search commands
  • Applying global conditions using GREP
Subject:
Design
Software:
InDesign
Author:
David Blatner

3. Using GREP for styles

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.

 
Share a link to this course

What are exercise files?

Exercise files are the same files the author uses in the course. Save time by downloading the author's files instead of setting up your own files, and learn by following along with the instructor.

Can I take this course without the exercise files?

Yes! If you decide you would like the exercise files later, you can upgrade to a premium account any time.

Become a member Download sample files See plans and pricing

Please wait... please wait ...
Upgrade to get access to exercise files.

Exercise files video

How to use exercise files.

Learn by watching, listening, and doing, Exercise files are the same files the author uses in the course, so you can download them and follow along Premium memberships include access to all exercise files in the library.
Upgrade now


Exercise files

Exercise files video

How to use exercise files.

For additional information on downloading and using exercise files, watch our instructional video or read the instructions in the FAQ.

This course includes free exercise files, so you can practice while you watch the course. To access all the exercise files in our library, become a Premium Member.

join now Upgrade now

Are you sure you want to mark all the videos in this course as unwatched?

This will not affect your course history, your reports, or your certificates of completion for this course.


Mark all as unwatched Cancel

Congratulations

You have completed InDesign: 10 Things to Know About GREP.

Return to your organization's learning portal to continue training, or close this page.


OK
Become a member to add this course to a playlist

Join today and get unlimited access to the entire library of video courses—and create as many playlists as you like.

Get started

Already a member?

Become a member to like this course.

Join today and get unlimited access to the entire library of video courses.

Get started

Already a member?

Exercise files

Learn by watching, listening, and doing! Exercise files are the same files the author uses in the course, so you can download them and follow along. Exercise files are available with all Premium memberships. Learn more

Get started

Already a Premium member?

Exercise files video

How to use exercise files.

Ask a question

Thanks for contacting us.
You’ll hear from our Customer Service team within 24 hours.

Please enter the text shown below:

The classic layout automatically defaults to the latest Flash Player.

To choose a different player, hold the cursor over your name at the top right of any lynda.com page and choose Site preferencesfrom the dropdown menu.

Continue to classic layout Stay on new layout
Exercise files

Access exercise files from a button right under the course name.

Mark videos as unwatched

Remove icons showing you already watched videos if you want to start over.

Control your viewing experience

Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.

Interactive transcripts

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.

Are you sure you want to delete this note?

No

Notes cannot be added for locked videos.

Thanks for signing up.

We’ll send you a confirmation email shortly.


Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

Keep up with news, tips, and latest courses with emails from lynda.com.

Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

   
submit Lightbox submit clicked
Terms and conditions of use

We've updated our terms and conditions (now called terms of service).Go
Review and accept our updated terms of service.