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/
KeyEventTranslations.tr
by copying the default. I am not sure which entry is responsible for the completion menu. Possible candidates are
"MoveNext",
"MoveNextExpression",
"MoveNextLine",
"MoveNextPlaceHolder",
"MoveNextWord",
"NextFunctionTemplate",
"SelectNext",
"SelectNextExpression",
"SelectNextLine",
"SelectNextWord",
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.
SelectNext
has as the default mapping:Item[KeyEvent["Right", Modifiers -> {Shift}], "SelectNext"],
So I guess this is not the right operation. $\endgroup$