I would like to use CTRL-N and CTRL-P to select the next or previous entry in the context-sensitive autocompletion menu of Mathematica 11.20 on macOS Sierra (10.12).

The questions

do not answer this.

I've already created the file

❯ ls ~/Library/Mathematica/SystemFiles/FrontEnd/TextResources/Macintosh/

by copying the default. I am not sure which entry is responsible for the completion menu. Possible candidates are


Searching the default file KeyEventTranslations.tr for KeyEvent["Down"] the only match is "MoveNextLine". There are a couple of matches for Down, however, with modifier keys. The following modification does not affect the keys which change the active entry in the completion menu

(* Cursor control *)
    Item[KeyEvent["n", Modifiers -> {Control}], "MoveNextLine"],
    Item[KeyEvent["p", Modifiers -> {Control}], "MovePrevious"],

which means I still have to use the arrow keys. This is pretty inconvenient because my hand has to move a quite long distance.

The answer https://stackoverflow.com/a/4209612/1057593 claims to provide all undocumented FrontEndTokens. However, I could not spot any token which looks like the correct one.

Remark For people who are used to text editors such as vim and emacs and are also struggling with the keyboard UI of Mathematica, see the question Using the Mathematica front-end efficiently for editing notebooks. One could consider to write the mathematica code outside of Mathematica, see e.g. http://wlplugin.halirutan.de/index.php/blog/7-how-to-use-idea-effectively-with-mathematica-code, http://library.wolfram.com/infocenter/MathSource/2584/, https://github.com/rsmenon/vim-mathematica.

  • $\begingroup$ Seems like you’re a good part of the way there, assuming one of those really does act on the autocompletion menu. I’d try the “SelectNext” myself. Alas I am not sure any of those will target that menu and I’m not even certain it is possible to target that menu. $\endgroup$
    – b3m2a1
    Dec 21, 2017 at 21:42
  • $\begingroup$ SelectNext has as the default mapping: Item[KeyEvent["Right", Modifiers -> {Shift}], "SelectNext"], So I guess this is not the right operation. $\endgroup$
    – Hotschke
    Dec 21, 2017 at 22:00
  • $\begingroup$ Of course, it's a valid question, but I'm a bit puzzled by how some people find it easier to press the awkward combination Ctrl-N than the up-arrow, especially on a Mac laptop which doesn't even have a Ctrl key on the right. $\endgroup$
    – Szabolcs
    Dec 22, 2017 at 10:10
  • $\begingroup$ @Szabolcs I have attached my MacBook to a 24" Display and use the keyboard getdigital.eu/Das-Keyboard-4C-Professional.html. Also I have remapped Capslock to Control as every decent human :-) would do. I am kidding but there are seriously good reasons to do this. No upvote for my question makes me wonder if the intersection of (emacs,vim) user and mathematica user is an empty set. $\endgroup$
    – Hotschke
    Dec 22, 2017 at 15:05
  • $\begingroup$ I use Vim and hate Ctrl-n and Ctrl-p. Now you have +1. $\endgroup$
    – Szabolcs
    Dec 22, 2017 at 15:30

1 Answer 1


Karabiner Elements: Vi-Style Arrows (Complex Modifications)

In order to keep your hands on the homerow, another option is to use a trigger key plus hjkl as arrow keys at system level.

I have picked https://pqrs.org/osx/karabiner/complex_modifications/#vi_style_arrows to use Option+hjkl as arrow keys. By default Option+hjkl gives you the letters ˙∆˚¬ which I do not use. You can also use Ctrl+hjkl and Cmd+hjkl which overwrite for me too many mappings I already use.

macOS system wide

  • Ctrl-H Delete previous character
  • Command-H Hide the windows of the front app.


  • Ctrl-K Complete Selection


  • Ctrl-K Enter digraph


  • Command-J Show View Options.
  • Command-K Open the Connect to Server window.
  • Command-L Make an alias of the selected item.

Remark For vim & mathematica user following two rules might be of interest too (link)

  1. Map Ctrl + [ to Escape
  2. Post escape if caps is pressed alone, left_ctrl otherwise

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.