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.

I've checked MathematicaPreferences, and poked around the options on the toolbar. However, I don't see a way to define new keyboard shortcuts in Mathematica.

I've used VIM for 10+ years, and I've rebound Ctrl+F to be Esc for the last decade or so. I would like to also use this shortcut in Mathematica, to have Ctrl+F be Esc, so hitting something like:

Ctrl+F S Ctrl+F

should give me capital Sigma.

Question: how do I define new keybindings in Mathematica?

(I have a CS background, so I'd prefer things that involve editing config files / writing scripts -- that would give me more power -- over clicking things in a GUI).

share|improve this question
    
why not rebind it at the OS level if you're married to it? Also see this related question: stackoverflow.com/q/5808695 Looks like vim users are pretty anal about their bindings... ;) –  rm -rf Jun 29 '12 at 0:46
    
There are want to rebind caps-lock to esc; but I only want to rebind ctrl-f to esc (my caps-lock is bound to ctrl). Truth be told, all I need is a turing-complete keyboard mapping language, and I'd be happy. –  user1602 Jun 29 '12 at 0:53
    
Changed title to reflect a more general problem, and added Q to customization wiki as perfect example. –  István Zachar Jun 29 '12 at 8:32
2  
You can use Autohotkey for a systemwise remap. It is easy as hell, and the script can be turned on/off on the fly anytime with a click (which is not true for changes made to KeyEventsTranslation.tr). –  István Zachar Jun 29 '12 at 8:39

1 Answer 1

up vote 9 down vote accepted

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 tree) and add the following modifications after EventTranslations[{ in the file:

Item[KeyEvent["f", Modifiers -> {Control}],
        FrontEndExecute[{
            FrontEnd`NotebookWrite[FrontEnd`InputNotebook[],
                "\[AliasDelimiter]", After]
        }]],
share|improve this answer
    
Also, since you're editing your .tr file, you might as well include these shortcuts for 〚〛 (or Part) too, while you're at it, as these are very useful and commonly used –  rm -rf Jun 29 '12 at 1:06
1  
I wonder, how easy is to maintain such changed system files as KeyEventTranslations.tr when someone changes to a new version of Mathematica and/or to a new computer? Can these customized files handled in a bunch? Would a software update revert these to default? –  István Zachar Jun 29 '12 at 8:35
5  
@IstvánZachar You can put a version of KeyEventTranslations.tr with your changes in $UserBaseDirectory/SystemFiles/FrontEnd/TextResources/Macintosh/ because this file is read before the KeyEventTranslations.tr` under $InstallationDirectory an so survives new Versions. –  Peter Breitfeld Jun 29 '12 at 9:33
    
@IstvánZachar As Peter said, the files in $UserBaseDirectory supersedes the installation files. In my answer too, I suggest modifying this file and not the installation file –  rm -rf Jun 29 '12 at 15:11

Your Answer

 
discard

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