Tag Info

Hot answers tagged

28

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:


16

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 FE`FC. 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

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

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


13

Referencing Szabolcs's answer, here is the code that must be added to KeyEventTranslations.tr: Item[KeyEvent["m", Modifiers -> {Control}], FrontEndExecute[{ FrontEnd`SelectionMove[FrontEnd`SelectedNotebook[], All, Cell], FrontEnd`FrontEndToken["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[ FrontEnd`AddMenuCommands["MenuListQuitEvaluators", {MenuItem["AddMenu &Quit", FrontEnd`KernelExecute[ToExpression["Quit[]"]], MenuKey["q", Modifiers -> {"Control"}], System`MenuEvaluator -> 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, ...


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.


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[{FrontEnd`NotebookWrite[FrontEnd`InputNotebook[], ...


10

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 ...


9

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"]] ...


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[{FrontEnd`NotebookApply[FrontEnd`InputNotebook[], ...


7

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


6

In the section of the manual about entering two dimensional input you can find the following quote. This may help. On a standard English-language keyboard, the character ^ appears as the shifted version of 6. Mathematica therefore accepts Ctrl+6 as an alternative to Ctrl+^. Note that if you are using something other than a standard English-language ...


6

Yes, you can use the shift key, too. So, in one stylesheet I have, I have defined MenuCommandKey -> "5" for Item and MenuCommandKey -> "%" for SubItem.


6

The file KeyEventTranslations.tr which can be found in the directory $InstallationDirectory/SystemFiles/FrontEnd/TextResources/Macintosh couples key events to actions in Mathematica. The two lines that define the behaviour of Home and End are Item[KeyEvent["Home"], "ScrollNotebookStart"], Item[KeyEvent["End"], "ScrollNotebookEnd"], To change the behaviour ...



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