Skip to main content
Bedazzled532
Inspiring
May 13, 2023
Answered

Give a Tab before and after an anchor marker using GREP

  • May 13, 2023
  • 2 replies
  • 1328 views

Hi

I have few paragraphs where I have put an anchor marker at the beginning of the line. 

I now want to give a tab before and after that anchor marker.

Currently I am using a GREP query which work only if I do find and replace one by one. The moment I do change all it deletes the anchored object also.

The query which I use is Find what: ^~a and Replace with:  \t$0\t

I have attached screenshots.

What am I doing wrong ?

Thanks.

This topic has been closed for replies.
Correct answer Bedazzled532

@Barb Binder Found a way to achieve what I mentioned in my question. Actually took help of some expert in Facebook Group. Sharing the solution here so that anyone who face the same issue can use this code.

It's an InDesign bug that GREP does not work well with Anchors sometimes. 
Here we have to run GREP two times. First at add a tab before the anchor and then again run GREP to add a tab char after the anchor.

To add a Tab char before use following:
F: ^(?=~a)
C: \t

To add a Tab character after the anchor use following:

F: ~a\K
C: \t

2 replies

Barb Binder
Community Expert
Community Expert
May 14, 2023

You are very welcome, @Bedazzled532.

 

~Barb

~Barb at Rocky Mountain Training
Barb Binder
Community Expert
Community Expert
May 13, 2023

Hi @Bedazzled532:

 

~a should be in parentheses so that InDesign can capture it and add it back with $0.

 

That said, Change works and Change all appears to remove them, but... check Story Editor. The anchors are still there. They just no longer appear in Layout view. I don't get it.

 

But here's a different approach: do one manually,  copy it to the clipboard and change by pasting. 

 

~Barb

 

~Barb at Rocky Mountain Training
Bedazzled532
Inspiring
May 13, 2023

@Barb Binder Thank you so much for the help. It seems that there is a bug. Anyway, I will follow your method. 

Thanks once again.

Regards