Skip to main content
Fjellfotografen
Participating Frequently
March 30, 2015
Answered

Shortcuts for placing text in brackets

  • March 30, 2015
  • 2 replies
  • 1037 views

Is there a script to place text in brackets in Indesign? I have a lot of text where some word need to be placed in brackets and would like to just highlight the word and use a shortcut to place it in brackets.

This topic has been closed for replies.
Correct answer TᴀW

You may also want to consider this. It will avoid having to carefully select the text, and simply place the brackets after the last word of the selection (or even just a flashing text cursor), and before the first word:

s = app.selection[0];

s.words[-1].insertionPoints[-1].contents = "]";

s.words[0].insertionPoints[0].contents = "[";

2 replies

TᴀW
Legend
March 30, 2015

Hold on. This is better, because it won't mess up any formatting in the

middle:

s = app.selection[0];

s.insertionPoints[-1].contents = "]";

s.insertionPoints[0].contents = "[";

id-extras.com | InDesign tools & scripts for typesetters, form designers, and translators
TᴀW
TᴀWCorrect answer
Legend
March 30, 2015

You may also want to consider this. It will avoid having to carefully select the text, and simply place the brackets after the last word of the selection (or even just a flashing text cursor), and before the first word:

s = app.selection[0];

s.words[-1].insertionPoints[-1].contents = "]";

s.words[0].insertionPoints[0].contents = "[";

id-extras.com | InDesign tools & scripts for typesetters, form designers, and translators
Fjellfotografen
Participating Frequently
March 30, 2015

Thanks Ariel, I'm new to script in Indesign, can you please give me a short description on how to apply the script.

TᴀW
Legend
March 30, 2015

Something like this should do the trick:

s = app.selection[0];

c = "["+s.contents+"]";

s.contents = c;

id-extras.com | InDesign tools & scripts for typesetters, form designers, and translators