Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

If one executes the following code

SetOptions[EvaluationNotebook[], InputAliases -> {"aa" -> 
 "AFunctionWithAVeryLongName[\!\(\*TagBox[FrameBox[\"input\"],\"Placeholder\"]\)]"}]

the front end will change ESC+a+a+Esc into a long expression with a placeholder. I want the placeholder selected after the replacement.

If I try to use SelectionPlaceholder, instead of Placeholder, then a character from AFunctionWithAVeryLongName gets selected.

If I try to include a tab at the end of the string,

SetOptions[EvaluationNotebook[], InputAliases -> {"aa" -> 
 "AFunctionWithAVeryLongName[\!\(\*TagBox[FrameBox[\"input\"],\"Placeholder\"]\:0009\)]"}]

the tab goes in literally as a tab character, not a tab command.

Also, I want the output to have a string, say "input", in the placeholder.

enter image description here

share|improve this question
1  
Related. The answer there by the user matTECmatica appears to answer your question. I think that code could be slightly improved, maybe also see my comment there. –  Jacob Akkerboom Aug 11 '13 at 14:49
    
Hector, you haven't answered my question: if as I believe this is not possible from InputAliases what alternatives are acceptable to you? What about a shortcut-key, or a palette button? –  Mr.Wizard Aug 12 '13 at 1:13
    
Unfortunately, I do not see how Mathematica would allow key modifiers for shortcuts. I am working on a palette button to be controlled by AutoHotkey. –  Hector Aug 13 '13 at 13:22
    
Hector, I'm not sure what you mean. If you doubt it is possible to create your own keyboard shortcuts please see this search result as it surely is. Are you going to post a new question? –  Mr.Wizard Aug 13 '13 at 14:11
1  
@Mr.Wizard I am looking for shortcuts available only when a package has been loaded (as opposed to system-wide ones). Also, I will post a new question because creating palette brought new challenges. –  Hector Aug 13 '13 at 14:28
add comment

1 Answer 1

up vote 5 down vote accepted

Please try:

SetOptions[EvaluationNotebook[], 
 InputAliases -> {
   "aa" -> RowBox[{"AFunctionWithAVeryLongName", "[", "\[SelectionPlaceholder]", "]"}]
 }
]

enter image description here

A placeholder with a name does not seem possible with Input Aliases.

share|improve this answer
    
Very nice! You were quick too :) –  Jacob Akkerboom Aug 11 '13 at 14:53
    
Duh!, the manual does say that InputAliases accepts "strings or box expressions." –  Hector Aug 11 '13 at 14:54
    
@Hector There are lots of things the manual says that I didn't understand until someone gave me an example, or sometimes several examples. –  Mr.Wizard Aug 11 '13 at 14:56
    
I updated the question to make explicit the requirement on the string within the placeholder … –  Hector Aug 11 '13 at 15:11
    
@Hector I'm not certain that is possible from an input alias (I'll be happy to see it if it is). Things like command completion templates are inserted programmatically and use e.g. SelectionMove to select the labels. At least that's my recollection. –  Mr.Wizard Aug 11 '13 at 15:15
show 4 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.