Edit FindChangeList to fix double hyphens & add fixed spaces?

Learn / Forums / InDesign Add-ons (Scripts, Scripting, and Plug-ins) / Edit FindChangeList to fix double hyphens & add fixed spaces?

Viewing 5 reply threads
  • Author
    Posts
    • #92218
      Faith Ishii
      Participant

      I’ve figured out how to do a series of Find and Replaces to fix double hyphens and add a fixed space in a certain way:

      Fixed space, e.g.:
      Text find et al. and replace with et^sal.

      Double hyphen:
      Grep find \b\w+?- and replace with ~-­$0 (inserts a discretionary hyphen before the hyphenated words)
      find -\w+?\b and replace with ~k­~-$0 (inserts a discretionary line break and discretionary hyphen before the hard hyphen)
      find ~k­~– and replace with -~k~- (transposes the discretionary line break and discretionary hyphen with the hard hyphen)

      This results in the words being allowed to break but only at the hyphen.

      I know it’s possible to add these to the FindChangeList to execute the series of actions much more quickly, but I have no experience with scripting and am at a loss as to how to edit the text file. I’ve tried using RecordFindChange and then adding the resulting text to FindChangeList but keep getting error messages.

      Can anyone help or point me in a better direction? It drives me crazy to have to go through all these steps all the time when I know that there’s a better way…

      Thanks!

    • #92222
      Aaron Troia
      Participant

      The FindChangeList script takes some getting used to, I personally prefer Multi-Find/Change 2.0 and would post a link if it didn’t appear that their site was down. But FindChangeList uses a little different GREP than InDesign’s Find/Change dialog. First you have to remember to double escape everything (ie periods, you have to do \\. not just \.), I played with them and at least got one working (it’s a little modified from what you had (using Keep (\K) as a positive look-behind which is zero-length so you dont have to worry about using a capture group number or $0 in the changeTo field.), still working/playing on the others.

      grep {findWhat:"\\w\\K\\-"} {changeTo:"~-"} {includeFootnotes:false, includeMasterPages:false, includeHiddenLayers:false, wholeWord:false}

      Aaron

    • #92249
      Aaron Troia
      Participant

      Et al fixed width space

      grep {findWhat:"(et) (al)"} {changeTo:"$1~s$2"} {includeFootnotes:false, includeMasterPages:false, includeHiddenLayers:false, wholeWord:false}

    • #92266
      Faith Ishii
      Participant

      Oh, this is fun! Thank you so much for this help, Aaron. I’ve modified your first bit as follows, which results in the addition of the discretionary line break and discretionary hyphen following the hard hyphen.

      grep {findWhat:”\\w\\K\\-“} {changeTo:”\-~k~-“} {includeFootnotes:false, includeMasterPages:false, includeHiddenLayers:false, wholeWord:false}

      Now I just have to figure out how to also add a discretionary hyphen before the word preceding the hard hyphen…

      I also see that there’s a 3.0 version of Multi-Find/Change available (https://www.automatication.com/index.php?id=24), which I’m going to experiment with as well. I appreciate that suggestion.

    • #92270
      Aaron Troia
      Participant

      No problem, I’m glad I could help :) I’m glad you were able to get that one search to work! I kept trying and it was not liking one of the special InDesign metacharacters and was displaying the wrong thing.

      I have used the Multi-Find/Change plugin and really liked it, it works really well and since it uses your saved Find/Change queries, it works better and offers more functionality than the script, not to mention its a lot easier to work in than the script.

    • #92439

      Try Mike’s Find/ChangebyList 2017. It is a free resource:
      https://trainingonsite.com/useful-resources/indesign-cc-2017-resources.html
      It accomplishes 17 or so common text cleanups, and won’t harm styled paragraphs. It fixes em dashes, en dashes, quote marks, and even turns apostrophes the right way up (when used next to 2-digit year references). From my testing, it will not harm or change paragraph styles.

Viewing 5 reply threads
  • You must be logged in to reply to this topic.
>