Message Boards Message Boards

Keyboard shortcut for "Evaluate Notebook"

Posted 6 years ago

I recently upgraded to Mathematica 11 for some side projects. I love the program, but I was annoyed to see that there is no keyboard shortcut for the Evaluate Notebook command. F8 appears to be unused in the normal configuration on Linux. So I’m posting a solution for adding F8 as a keyboard shortcut for Evaluate Notebook:

If you are on Linux, all you have to do is edit /usr/local/Wolfram/Mathematica/11.2/SystemFiles/FrontEnd/TextResources/X/MenuSetup.tr

  1. Make a backup of MenuSetup.tr
  2. Open MenuSetup.tr
  3. Search for “Evaluate Notebook”
  4. You’ll find the correct line (there is only one). Add ‘, MenuKey[“F8”, Modifiers->{}]’ after “EvaluateNotebook”
  5. The revised line should read ‘MenuItem[“Evaluate N&otebook”, “EvaluateNotebook”, MenuKey[“F8”, Modifiers->{}]],’
  6. Re-launch Mathematica, and you should see F8 next to the Evaluate Notebook command. Try it out.
  7. Success!

Is there some reason why there is no keyboard shortcut for Evaluate Notebook? I am at a loss because it is simple to add one.

POSTED BY: Andrew Watters
5 Replies

This works on Windows as well-- edit the same file MenuSetup.tr in:

C:\Program Files\Wolfram Research\Mathematica\13.1\SystemFiles\FrontEnd\TextResources\Windows

You'll have to open Notepad as an administrator. I did the edit, but the first re-launch didn't change the menu. I discovered this is because I left a copy of the original file in the same folder. Apparently, the FrontEnd searches for the first file named MenuSetup. I removed the copy from the folder and it worked.

POSTED BY: Andrew Watters

Or perhaps a keyboard shortcut to restart the kernel and then run the entire notebook as a single operation would be a useful time-saving feature?

POSTED BY: Ian Williams

Note: do not copy and paste the above inserts into your MenuSetup.tr file or Mathematica will give you an error message on launch. This is because the quotes around the "F8" or "E" must be straight quotes, not curly quotes. I don't know why they showed up as curly quotes in this post, but I realized the error when I copied and pasted from my post after installing 11.3. Lol.

POSTED BY: Andrew Watters

This works on Mac also. I chose Command-Option-E because F8 is assigned to iTunes play/pause by default. Here is the solution:

Edit /Applications/Mathematica.app/Contents/SystemFiles/FrontEnd/TextResources/Macintosh/MenuSetup.tr

  1. Make a backup of MenuSetup.tr
  2. Open MenuSetup.tr
  3. Search for “Evaluate Notebook”
  4. You’ll find the correct line (there is only one). Add ‘, MenuKey[“E”, Modifiers->{"Command","Option"}]’ after “EvaluateNotebook”
  5. The revised line should read ‘MenuItem["Evaluate Notebook", "EvaluateNotebook", MenuKey["E", Modifiers->{"Command","Option"}]],’
  6. Re-launch Mathematica, and you should see Command-Option-E next to the Evaluate Notebook command. Try it out.
  7. Success!
POSTED BY: Andrew Watters

Probably because it only takes two Ctrl+a and then Shift+Enter.

About your modification, it is good idea to not mess with installation directory but to create correspoding path in $UserBaseDirectory.

p.s. here is a mma.se topic about the same issue: 33197. I find your solution better then using KeyEventTranslations.tr.

POSTED BY: Kuba Podkalicki
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract