• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

GREP Style to Add Space

Guest
Jun 20, 2019 Jun 20, 2019

Copy link to clipboard

Copied

Good afternoon,

I have antoher GREP style which I need but can't figure out on my own.  I need to create a fixed amount of space (either in millimeters or via a specific character, like an en dash) between a colon and its following character but only at the beginning of the paragraph.  And it also needs to replace whatever existing space(s) might exist between the colon and the next character.

As you can see below, for interviews, we always have a name or initials followed by a colon.  A normal space after that doesn't look very good.  And different editors might add different kinds of spaces after the colon, which is why it should replace the existing space.  And the automatic spacing should not be applied to colons later in the paragraph.  Any help would be really great as this would save me a lot of time from having to manually format every section in 50-page+ interviews.

Here is how it should look with ample space after the first colon.  Notice the second colon later in the same first line!

Screen Shot 2019-06-20 at 3.04.22 PM.png

Thanks!

Warmly,

Jonathan

Views

2.6K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Mentor ,
Jun 20, 2019 Jun 20, 2019

Copy link to clipboard

Copied

not thoroughly tested, but might work:

^(.+?):\K\h

change to whatever you need

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Mentor ,
Jun 20, 2019 Jun 20, 2019

Copy link to clipboard

Copied

Just a note: since you’re going to replace a found character (space after the first colon), you won’t be able to use this regex as a part of Paragraph style. Only Find/Change will work.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jun 20, 2019 Jun 20, 2019

Copy link to clipboard

Copied

Thanks so much for the GREP.  Am I correct that the needed Find/Change, in order to replace the space, would have to be done manually after all my typography is finished, or is there a way for a Find/Change to work continuously?  If that's the case, that I would have to manually trigger the Find/Change, maybe a better solution is to manually delete all the spaces between the colon and the text and then use GREP to automatically add space or a space character.  This takes time but at least I would be able to change the amount of spacing globally and not have to go through each instance multiple times if/when I want to try out different spacing.  Do you agree?  What the GREP be the same for this?  Thanks again!!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Mentor ,
Jun 20, 2019 Jun 20, 2019

Copy link to clipboard

Copied

GREP as a part of paragraph style options can not add, remove or replace any characters. Just think about it as a style. Styles change formatting, not content.

is there a way for a Find/Change to work continuously?

Nope.

maybe a better solution is to manually delete all the spaces between the colon and the text and then use GREP to automatically add space or a space character.

No point doing this. Remember, you can't add anything using just style! When your text is all here, just run Find/Change once. Think about Scope setting, maybe restrict replacements to specific paragraph style… You know your project better. That said, use settings in F/C panel window, and then hit Change All. If settings are correct, no need to stop on every found space.

A drawback vs GREP as a style: any newly added text will not catch those earlier changes automatically. No way.

But you always can repeat that F/C operation on the whole text - it will do no harm.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Mentor ,
Jun 20, 2019 Jun 20, 2019

Copy link to clipboard

Copied

JonSimons  wrote

maybe a better solution is to manually delete all the spaces between the colon and the text and then use GREP to automatically add space or a space character.

Well, thinking again, one may find this as a possible workflow, too.

1. To eliminate space after first colon using F/C and this query: ^(.+?):\K\h

2. In Paragraph style include GREP ^(.+?)\K: and apply Charstyle, which sets Tracking to a rather big value, say, 500.

Effectively this would work the same. Still no big advantages, since if you add more text you will need to run F/C again to remove spaces after the first colons in your added text, only then your GREP style will come into play *automatically*.

That said:

Option 1: run F/C; maybe run again later.

Option 2: run F/C; use GREP style; maybe run F/C again later.

Up to you.

JonSimons  wrote

This takes time […]

Running F/C won't take any significant amount of time, really.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jun 24, 2019 Jun 24, 2019

Copy link to clipboard

Copied

LATEST

Thanks so much for this!  I might have a followup question but only after I spend some more time experimenting with your suggestions.

Warmly,

Jonathan

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines