I would like an AppleScript to start from my current cursor location (or the end of the current selection if there is one), scan forward to the next ";" or "(", then select all text until before the next ")" or ";". Then drop any spaces or "[" or "]" from each end of the selection.

If I were to do this with "brute force", it would look like this:

  1. step cursor forward until I pass "(" or ";"
  2. continue stepping forward until I reach a character that is not " " or "[".
  3. begin selection
  4. select forward until I reach ")" or ";"
  5. reduce selection until previous character is not " " or "]"


If my cursor is at the beginning of the block:

JSONSetElement ( json ; [ keyOrIndexOrPath ; value ; type ]; [ keyOrIndexOrPath ; value ; type ]; )

I want the AppleScript to first select "json", then "keyOrIndexOrPath", then "value", then "type", then "keyOrIndexOrPath", etc.

Average ( field {; field...} )

Would select "field {", then "field...}"

  • The application is FileMaker. I have no choice over the environment. I could design a FileMaker app to allow editing text in this way, but that doesn't help in the native FileMaker dialogs where I have no control. I did realize that I could use option-Left/Right to navigate between words and Shift-Option-Left/Right to select words. That helps me a lot and so I may abandon this mission! – Jason Wood Mar 31 at 2:58

You must log in to answer this question.

Browse other questions tagged .