9 Replies Latest reply on Mar 8, 2016 4:19 AM by Renisus

    Shortcut for Variable?

    Renisus Level 1

      Hi,

      I created custom text variable. Because I want here and there to place this text in middle of some text.

      Is there a way to create shortcut key for "Insert variable"?

       

      Thanks,

      Ran

        • 1. Re: Shortcut for Variable?
          Peter Spier Most Valuable Participant (Moderator)

          apparently not directly by editing the keyboard shortcuts, but if you were to use a script to insert the variable you could assign a shortcut to the script. Ask over in InDesign Scripting

          • 2. Re: Shortcut for Variable?
            Peter Kahrel Adobe Community Professional & MVP

            You can use InDesign's Quick Apply to insert (among other things) text variables.

            • 3. Re: Shortcut for Variable?
              Renisus Level 1

              Thanks, I will ask there.

              • 4. Re: Shortcut for Variable?
                Renisus Level 1

                Thanks, but not quick enough.

                • 5. Re: Shortcut for Variable?
                  Renisus Level 1

                  Actualy I want to save some text lets say "Blah blah blah" and every time I press shortcut it will add this phrase inside my text block whereever my cursor is. Like copy paste.

                  Because I didn't find a way, I thought about using variable instead.

                  I heard about TenClips - small program that can save up to 10 copys and assign them shortcuts.

                  Is there a way to do it in Indesign?

                  • 6. Re: Shortcut for Variable?
                    Peter Kahrel Adobe Community Professional & MVP

                    Brings back memories of WordPerfect, which let you define all kinds of quick shortcuts. Here's a take on that. Two scripts: one to define keys, the other, to use shortcuts.

                     

                    // Select some text, then run this script. Enter a number between 0 and 9 inclusive.
                    // The script creates a custom text variable with the name 'QuickVar' followed by the number
                    // using the text selected in the document
                    
                    if (app.selection.length > 0 && app.selection[0].hasOwnProperty ('baseline')) {
                      x = prompt ('Enter a number (0-9):', '0', 'Quick var');
                      if (/^[0-9]$/.test(x)) {
                        if (app.documents[0].textVariables.item('QuickVar'+x).isValid) {
                          app.documents[0].textVariables.item('QuickVar'+x).variableOptions.contents = app.selection[0].contents;
                        } else {
                          app.documents[0].textVariables.add ({
                            name: 'QuickVar'+x,
                            variableType: VariableTypes.CUSTOM_TEXT_TYPE,
                            variableOptions: {contents: app.selection[0].contents}
                          });
                        }
                      }
                    }
                    

                     

                    To use the text variable with a shortcut key, save this script in your scripts folder, e.g. using the variable's name (but it can be any name), using the file type jsx: quickvar0.jsx

                     

                    if (app.selection.length > 0 && app.selection[0] instanceof InsertionPoint) {
                      app.selection[0].textVariableInstances.add ({associatedTextVariable: app.activeDocument.textVariables.item ('QuickVar0')});
                    }
                    

                     

                    (You might as well copy the script to quickvar1.jsx, quickvar2.jsx, etc. Don't forget to change the name of the variable in the script.)

                     

                    Pressing the shortcut key inserts the variable's content at the insertion point.

                     

                    Peter

                    • 7. Re: Shortcut for Variable?
                      Peter Spier Most Valuable Participant (Moderator)

                      Another possibility might be to set up an auto-correct entry to type a few characters and have ID automatically correct to the phrase you want.

                      • 8. Re: Shortcut for Variable?
                        Peter Kahrel Adobe Community Professional & MVP

                        Hadn't thought of that one -- I'm a bit single-track minded

                        • 9. Re: Shortcut for Variable?
                          Renisus Level 1

                          Hi Peter and Pkahrel,

                           

                          Didn't try the script. Sure it's work. Was for my client.

                          The auto correct is genius and simple solution that I Hadn't thought about too.

                           

                          By the way the auto correct dosen't recognize special characters such as em space. In cases like that I think the shourtcut for variable with a script it's the best.


                          Thanks so much,

                          Ran