# How to set InputAlias for all future notebooks that are opened in current session?

This code

(SetOptions[#1, InputAliases -> {"xx" -> "X"}] & ) /@ Notebooks[];


will define the alias [esc]xx[esc] to be replaced with X in the front-end for all notebooks that are currently open.

However, I would also like the InputAlias to be applied to new notebooks that will be opened during the current session.

Is it possible to modify the code above to do this?

CurrentValue[$FrontEndSession, {InputAliases, "xx"}] = "X"  or, if you want the new settings to persist across sessions, use CurrentValue[$FrontEnd, {InputAliases, "xx"}] = "X"

• OP probably wants this to be preserved after session too. – Kuba Dec 13 '14 at 17:53
• @Kuba, updated just in case that's what the OP wants. – kglr Dec 13 '14 at 18:41
• I don't know, but now it is just a global setting so not the case either. – Kuba Dec 13 '14 at 18:44

First of all, if you use:

SetOptions[EvaluationNotebook[], InputAliases -> {"xx" -> "X"}]


then you will replace all aliases with this one. But if you only want to add new one, there is a convenient way to add a suboption:

CurrentValue[EvaluationNotebook[], {InputAliases, "xx"}] = "X"


Now, all previous aliases are preserved.

Ok, to the point. I don't know of any event/option that can help you. But since you are using FrontEnd anyway, maybe tiny Palette in the corner is what you can accept:

CreatePalette[
Dynamic[Notebooks[];
Print[DateList[], " updated aliases"];
Scan[
(CurrentValue[#, {InputAliases, "xx"}] = "X") &,
Notebooks[]
];
Style["\[FreakedSmiley]", 18, Bold]

]
]


So each time you open/close a notebook it will reevaluate. Feel free to delete Print line.

• Thanks for the explanation about SetOptions vs CurrentValue; that is most useful. The tiny palette is a very amusing, and I will use it for myself frequently. But I feel that it would be inappropriate to have that in a package that I will share with others :-D – QuantumDot Dec 13 '14 at 21:44
• @QuantumDot Yeah, but, if it works, it's not silly :P Could you say more about notebooks that are meant to be affected by this? All notebooks opened, or created, or somehow related to package? – Kuba Dec 13 '14 at 21:56
• Two examples: (1) if the user wants to open a new window (as a scratch pad, for example) and wants to do a few calculations using the package functions in the new window, it would be nice to be able to use the aliases there, too. (2) my package will also have documentation that is embedded with the Wolfram doc center. It would also be nice to have aliases working in the pages there, too. The answer CurrentValue[EvaluationNotebook[], {InputAliases, "xx"}] = "X" seems to do what I need. – QuantumDot Dec 13 '14 at 22:18
• @QuantumDot but this only sets aliases for one notebook. the question is broader, right? – Kuba Dec 13 '14 at 22:37
• oops.. you're right: I meant to say that kguler's answer CurrentValue[\$FrontEndSession, {InputAliases, "xx"}] = "X" is what I really needed (it applies to future notebooks too). – QuantumDot Dec 15 '14 at 4:08