It is very handy to have shortcuts for frequently used glyphs, e.g. [[, ]], <|, |>, and ->. I know already that we can do this by modifying KeyEventTranslations.tr located in
FileNameJoin[{
$InstallationDirectory,
"SystemFiles",
"FrontEnd",
"TextResources",
"Macintosh"
}]
Working with US keyboard layout, I added the following to the file:
...
Item[KeyEvent[">", Modifiers -> {Control}],
FrontEndExecute[{
FrontEnd`NotebookWrite[FrontEnd`InputNotebook[],"\[AliasDelimiter]",After],
FrontEnd`NotebookWrite[FrontEnd`InputNotebook[],"->",After],
FrontEnd`NotebookWrite[FrontEnd`InputNotebook[],"\[AliasDelimiter]",After]
}]
],
Item[KeyEvent["[", Modifiers -> {Shift,Control}],
FrontEndExecute[{
FrontEnd`NotebookWrite[FrontEnd`InputNotebook[],"\[AliasDelimiter]",After],
FrontEnd`NotebookWrite[FrontEnd`InputNotebook[],"<|",After],
FrontEnd`NotebookWrite[FrontEnd`InputNotebook[],"\[AliasDelimiter]",After]
}]
],
Item[KeyEvent["]", Modifiers -> {Shift,Control}],
FrontEndExecute[{
FrontEnd`NotebookWrite[FrontEnd`InputNotebook[],"\[AliasDelimiter]",After],
FrontEnd`NotebookWrite[FrontEnd`InputNotebook[],"|>",After],
FrontEnd`NotebookWrite[FrontEnd`InputNotebook[],"\[AliasDelimiter]",After]
}]
],
...
This worked splendidly for the last two or three major releases of Mathematica. But now in version 12, precisely what Szabolcs anticipated here happened to me: Seemingly, new shortcuts
- Shift+Ctrl+.,
- Shift+Ctrl+[, and
- Shift+Ctrl+]
have been added, ruining my established workflow. Actually, I am not sure that these shortcuts are new, but starting with version 12, my former approach does work anymore. At least Shift+Ctrl+. seems to be remapped to something related to notebook cell selection. Shift+Ctrl+,, another shortcut that I remapped and that I use often, is already present in version 11.3 -- but the remapping worked well. So maybe the order in which the shortcuts are loaded when the FrontEnd starts has changed?
I don't use these shortcuts in the new built-in way; I'd rather prefer to overwrite them with my old settings because I #!@&ing don't want to relearn typing every time a new version is realeased!
I also found the "Shortcuts`" package by Rolf Mertig, but as Rolf pointed out, it does not seem to work anymore (I have to admit that I have not tried it yet).
Has anybody found a robust, future-proof solution for this?
MenuSetup.tr? – Mr.Wizard Apr 27 '19 at 10:39MenuSetup.tr, I was able to find the lineMenuItem["Extend Selection", "ExpandSelection", MenuKey[".", Modifiers->{"Control"}]],but that should not modify Shift+Ctrl+. or should it? Neither did I find any further remappings of ">" or "." that would fit the pattern... – Henrik Schumacher Apr 27 '19 at 11:10tr-files... – Henrik Schumacher Apr 27 '19 at 11:19FileNameJoin[{$UserBaseDirectory, "SystemFiles", "FrontEnd", "TextResources", "Macintosh"}]instead? I tried givingShift+Ctrl+.a new short cut there, and it worked fine for me. – Carl Woll Apr 27 '19 at 14:16$UserBaseDirectoryand had Mathematica recreate it on relaunch before creatingFileNameJoin[{$UserBaseDirectory, "SystemFiles", "FrontEnd", "TextResources", "Macintosh"}]and copying my oldKeyEventTranslations.trthere. =/ Maybe. I should consider a fresh reinstall of Mathematica on Monday... – Henrik Schumacher Apr 27 '19 at 14:39KeyEventTranslations.trshould be manipulated only with Mathematica shut down (and with an external editor). And that is what I did. Several times by now. =| – Henrik Schumacher Apr 27 '19 at 15:04Import["http://www.mertig.com/s.m"]– Rolf Mertig Apr 27 '19 at 19:24Item[KeyEvent["q", Modifiers -> {Shift, Option}], FrontEndExecute[FrontEndToken[SelectedNotebook[], "EvaluatorQuit", Automatic]]],
to force the Kernel to quit. With version 12, when I typed the key sequence instead I saw the character Œ inserted. When I switched to use Modifiers -> {Shift, Control}, the shortcut started working.
Is there any built-in variable that describes the search path for keyboard overrides?
– Spencer Rugaber May 01 '19 at 13:22