How-To: (and where) define function aliases in Mathematica for use on any new laptop?

I want to properly configure aliases for Mma functions.

I am currently copying and pasting several aliases into a cell in a new laptop, for example:

 tf:=TableForm
 fi:=FactorInteger
 re:=RegularExpression

etc.

When I searched for aliases in the document, I found descriptions of the Esc ... Esc method and the chapter "Defining Custom Notations". I was hoping to find an initialization file to define aliases, I suppose. I am a little confused at the moment.

Question: - What is the general / correct / best way to define the function aliases that you use in any new laptop?

+5
source share
3 answers

, . ,

SetOptions[EvaluationNotebook[], 
  InputAliases -> Join[InputAliases/.Options[EvaluationNotebook[], InputAliases],
    {"tf" -> TableForm, "fi" -> FactorInteger, "re" -> RegularExpression}]]

. ( . , .)

, :

  • $FrontEnd ( Notebook).
  • Option Inspector (Global Preferences) > Editing Options > InputAliases . ( , .)
  • Mike .

init.m, FileNameJoin[{$UserBaseDirectory, "FrontEnd", "init.m"}].

, "init.m" "l=" -> \[LongEqual], .


, , "tf" TableForm, , -

"tf" -> InterpretationBox[StyleBox["tf", FontSlant -> Italic, 
          FontColor -> GrayLevel[0.5], Selectable -> False], TableForm]

, ( ).

tf

tf TableForm, Ctrl-Shift-I, .. InputForm.

+7

, , , , - - - ( Begin, End, BeginPackage EndPackage, Global`, ). init.m, M. init.m SO:

Init.m

$Pre :

$Pre = 
  Function[code, 
      Unevaluated[code] /. {
        HoldPattern[tf] :> TableForm, 
        HoldPattern[fi] :> FactorInteger, 
        HoldPattern[re] :> RegularExpression
      }, 
      HoldAll]

( init.m, ). , "" , , , . , ​​ , . , , , $Pre - , , FrontEnd.

+7

FWIW :

Cell[StyleData["Input"],

  InputAutoReplacements->{"hw"->"hello world"},

  InputAliases->{"tf"->"TableForm"}

]
+7

All Articles