Tag Info

31

Some approaches are discussed in this question on StackOverflow. Original references to these go to Szabolcs's webpage and a MathGroup posting by Mr.Wizard. To summarize, you copy the file: $InstallationDirectory/SystemFiles/FrontEnd/TextResources/Macintosh/KeyEventTranslations.tr to$UserBaseDirectory/ (with the same directory tree) and add the following ...

19

You need to add the following to KeyEventTranslations.tr: Item[KeyEvent["Tab", Modifiers -> {Control}], FrontEndExecute[FrontEndToken["CycleNotebooksForward"]]], Item[KeyEvent["Tab", Modifiers -> {Shift, Control}], FrontEndExecute[FrontEndToken["CycleNotebooksBackward"]]], This will map Control-Tab and Control-Shift-Tab to cycling between ...

19

Do you mean CtrlShiftK? After typing Plo, press the key combination CtrlShiftK and a window will appear with possible options: As pointed by Yves，CtrlK will also work，but CtrlShiftK will work differently if you finish the function name. For an example, Type Plot3D; Use CtrlShiftK; Mathematica will show:

17

Shorthand notations: All those shorthand notations are well documented. For double struck letters like $\mathbb{A}$, use EscdsA, where ds stands for "double struck" For script letters like $\mathcal{A}$, use EscscAEsc, where sc stands for — you guessed it — "script". Creating your own aliases: To create your own aliases, use InputAliases. I use it to ...

16

This is obsolete in Mathematica 9, which automatically includes contexts in completions. Undocumented function: use at your own risk, subject to change in future versions, etc.... The function you're interested in is FEFC. It's been around for a while (here's a Mathematica Journal article that references it, near the end) although it has ...

16

Ah, figured it out: Panel @ DynamicModule[{input = ""}, Column[{TextCell["Enter your text here:"], EventHandler[ InputField[Dynamic[input], String, ContinuousAction -> True, FieldSize -> {40, 7}], "ReturnKeyDown" :> FrontEndExecute[{NotebookWrite[InputNotebook[], "\n", After]}] ], Dynamic@InputForm[input]}]]

16

Here are four approaches to setting up keyboard shortcuts. The last is the best! AddMenuCommands First examples using notebook manipulation, (as you tried): This example adds a command to the Insert menu, with a key combination Control+U (normally the underline command). This addition just lasts for the session, but could be added to an init file. ...

14

The keyboard shortcut for underscripts has now been changed to ctr-4 (ctr-$). So, to enter your Sum[expr, {n, 1, 10}], you should type escsumesc ctr-$n=1ctr-%10 ctr-spaceexpr Another option is to type the overscript ctr-& first and then use the ctr-% shortcut to move to the underscript position. Not all of the tutorials have been updated (and if you ...

14

Try using this: FrontEndExecute[ {FrontEndNotebookFind[FrontEndSelectedNotebook[], "Output", All, CellStyle, AutoScroll->False], FrontEndFrontEndToken["Clear"]}] (Untested in KeyEventTranslations.tr, but works as a button!) Regarding automating confirming the dialog---I don't think it is possible from within ...

14

In this context it might be useful to remark that if you enter escsumtesc you'll get a complete sum template with your cursor already at the bottom: I feel this is much easier than going through the other shortcuts. The same works for products: escprodtesc indefinite integrals: escinttesc and definite integrals: escdinttesc The 't'-s at the ...

13

Changing shortcuts isn't that complicated. All you have to do is change one line in the file KeyEventTranslations.tr in a location in your file system specified by this command: FileNameJoin[{$InstallationDirectory, "SystemFiles", "FrontEnd", "TextResources",$OperatingSystem}] Locate the following line in a text editor and change the key into the one ...

13

Referencing Szabolcs's answer, here is the code that must be added to KeyEventTranslations.tr: Item[KeyEvent["m", Modifiers -> {Control}], FrontEndExecute[{ FrontEndSelectionMove[FrontEndSelectedNotebook[], All, Cell], FrontEndFrontEndToken["Clear"] }]], I chose Ctrl+M at random; change it to whatever you want. See this ...

13

Besides the nice real handy option suggested by @yulinlinyu (more here) you can also use text-based interface to find completion for your half-typed function. It is not that fast, but has its own advantages. Try executing this: ?Plot* and you'll get this nice table of possible functions that complete your input. If you click on any you'll get short ...

12

This will add Quit to Control+Q (and Alt+V Q Q): FrontEndExecute[ FrontEndAddMenuCommands["MenuListQuitEvaluators", {MenuItem["AddMenu &Quit", FrontEndKernelExecute[ToExpression["Quit[]"]], MenuKey["q", Modifiers -> {"Control"}], SystemMenuEvaluator -> Automatic]}]] It only persists for the front end session. Usually I keep ...

12

To clarify the situation: In Version 9 on Windows and OS X, there is a new Make Template system which supports multiple templates for built-in functions. As part of the new system, unfortunately a bug was introduced which makes it ignore the usage statement for user-defined functions. This bug has been confirmed and we hope to fix it in a future release, ...

12

You can see what can be done by running (maybe inspecting it in a browser first) Get["http://www.mertig.com/shortcuts.m"] This code will generate a modified copy of the default KeyEventTranslations.tr in : FileNameJoin[{$UserBaseDirectory, "SystemFiles", "FrontEnd", "TextResources", Switch[$OperatingSystem, "MacOSX", "Macintosh", ...

11

I usually press the down key until I get out of the cell, then press shift-up to select it. Here are two buttons that will select or delete the whole cell for you: select = Button["Select Cell", SelectionMove[SelectedNotebook[], All, Cell]] delete = Button["Delete Cell", SelectionMove[SelectedNotebook[], All, Cell]; FrontEndTokenExecute["Clear"]] ...

11

Actually, Mathematica does know these words, but requires a bit of prodding to suggest them. You can add additional word suggestions via the Options Inspector, but I don't think there is a general way to customize the ordering of the words that appear in the suggestions popup menu.

11

Thanks to everyone for the helpful comments. Here's the exact procedure I used to fix this (specific to Mac OS X, version 10.8 if that matters, and Mathematica 8, but it should be analogously applicable to other versions and operating systems): Close Mathematica Delete the keymap cache. For me this was in ~/Library/Mathematica/FrontEnd/8.0 ...

10

There are some known bugs where the caret can get, as you say, "trapped" when using the up/down arrow keys. I.e., further presses of the up/down key at certain points in typesetting cells can just do nothing. However, it has always been my experience that left/right arrow will continue to work, and that usually one or two presses will get you to a point ...

10

Edit the KeyEventTranslations.tr file in a plain text editor by adding the following definitions to the first section of the file: EventTranslations[{ (* Custom shortcuts *) Item[KeyEvent["[",Modifiers->{Control}], FrontEndExecute[{FrontEndNotebookWrite[FrontEndInputNotebook[], ...

9

Since you want this functionality to be able to insert aliases using the EscshortcutEsc syntax, you can edit the KeyEventsTranslation.tr file to achieve this. Copy the following file: $InstallationDirectory/SystemFiles/FrontEnd/TextResources/Macintosh/KeyEventTranslations.tr or its equivalent on your system to$UserBaseDirectory/ (with the same directory ...

9

Here is a widget which I constructed some time ago for my purposes. This is an InputField as well, but it operates on boxes, and as a bonus, the standard syntax highlighting works inside it: ClearAll[codeInputField]; Attributes[codeInputField] = {HoldFirst}; Options[codeInputField] = { BaseStyle -> {FontSize -> 14, FontWeight -> Plain, ...

8

You may also use Ctrl+Shift+K, or ⌘+Shift+K to insert a template with the basic syntax already filled in with named placeholders.

8

It is the same F1 key. If the cursor is anywhere in the name of the function adjacent to any function-name letter, then pressing F1 will bring the corresponding function documentation page. Mathematica 9 Context-Sensitive Input Assistant (or see this video) provide a set of useful options. For example this will appear as you type and clicking red-circled ...

7

You can also use hotstrings as a way of autocompletion. By using such replacements, words are immediately replaced by another word on typing a space after the hotstring: CreateDocument[{}, InputAutoReplacements -> {"sync" -> SynchronousInitialization}] You can set such replacements globally under Option Inspector (CtrlShiftO). Of course no one would ...

7

I do believe that it should still work under V9, however I personally have added my shortcuts to MenuSetup.tr rather than KeyEventTranslations.tr and they read: Menu["&Typesetting", { ... Delimiter, (*My typesetting shortcuts*) MenuItem["Matching ()", FrontEndExecute[{FrontEndNotebookApply[FrontEndInputNotebook[], ...

7

Font for the Greek letters is defined in UnicodeFontMapping.tr: ... 0x03B1 N -2 0x61 # \[Alpha] 0x03B2 N -2 0x62 # \[Beta] 0x03B3 N -2 0x67 # \[Gamma] 0x03B4 N -2 0x64 # \[Delta] 0x03F5 N 2 0x65 # \[Epsilon] 0x03B5 N -4 0xb6 ...

7

You could add a trap to DocumentationHelpLookup which is called when F1 is pressed: Unprotect[DocumentationHelpLookup]; DocumentationHelpLookup[link_String, nb_, lang_String, opts : OptionsPattern[]] := Block[{$inblock = True}, lookedup[link] = True; DocumentationHelpLookup[link, nb, opts]] /; ! TrueQ[$inblock] You can add whatever code ...

7

Here are two I have found: http://marwww.in2p3.fr/Master2-P3TMA/Programme/MiseAniveau/stock/mathqkref.pdf http://math.msstate.edu/events/reu/reu2010/leftitems/ma-refcard-la.pdf I'm not sure these are great but they are the best I've found. (I take it these are along the lines of what you want, correct?)

Only top voted, non community-wiki answers of a minimum length are eligible