I asked the following question before, but I do not think it has been fully answered.
By default, we use Shift+Enter to evaluate the current cell, and use Enter to get a new line. Is there a way to switch the two, i.e., use Enter to evaluate the current cell, and use Shift+Enter to get a new line (like in Maple)?
The answer is related to modifying the file "KeyEventTranslations.tr," part of which is
(* Evaluation *)
Item[KeyEvent["Enter"], "EvaluateCells"],
Item[KeyEvent["KeypadEnter"], "EvaluateCells"],
Item[KeyEvent["Return", Modifiers -> {Shift}], "HandleShiftReturn"],
Item[KeyEvent["KeypadEnter", Modifiers -> {Shift}], "EvaluateNextCell"],
Item[KeyEvent["Enter", Modifiers -> {Shift}], "EvaluateNextCell"],
Item[KeyEvent["Return", Modifiers -> {Shift, Control}], Evaluate[All]],
Item[KeyEvent["Return", Modifiers -> {Option}], "SimilarCellBelow"],
Item[KeyEvent["Escape"], "ShortNameDelimiter"],
I tried many different ways to modify this file, but I never succeeded. I have many confusions about this file.
The first item above is
Item[KeyEvent["Enter"], "EvaluateCells"]. It seems that Enter is already used to evaluate cells, but it is not. I tried to modify this line asItem[KeyEvent["Enter"], "EvaluateNextCell"],Item[KeyEvent["Return"], "EvaluateCells"], andItem[KeyEvent["Return"], "EvaluateNextCell"], but in any case, Enter cannot evaluate the cell. (I am using a Windows laptop computer)If I switch
EvaluateNextCellandLinebreakinItem[KeyEvent["Enter", Modifiers -> {Shift}], "EvaluateNextCell"]andItem[KeyEvent["Return"], "Linebreak"](according to Jacob's answer), then both Shift+Enter and Enter are for a line break.What is difference between
EvaluateCellsandEvaluateNextCell? What doesHandleShiftReturnmean? In a Windows laptop, does Return play a role?According to the link given by Szabolcs, we can evaluate the following in a notebook.
SetOptions[EvaluationNotebook[], NotebookEventActions -> {"ReturnKeyDown" :> FrontEndTokenExecute["EvaluateCells"], {"MenuCommand", "HandleShiftReturn"} :> FrontEndTokenExecute["Linebreak"]}]This works for only one notebook in which the above command is evaluated, not for all notebooks. A puzzle to me is that even if we delete the above command, and reopen this notebook, the function of Enter and Shift+Enter is still switched (only for this notebook). I wonder where this information is stored.
Could you give a clear answer on how to modify the file "KeyEventTranslations.tr"?
SystemOpen@First@FileNames["KeyEventTranslations.tr", $InstallationDirectory, 8], itemsItem[KeyEvent["Enter", Modifiers -> {Shift}], "EvaluateNextCell"]andItem[KeyEvent["Return"], "Linebreak"]. Make a backup! – Jacob Akkerboom Mar 17 '14 at 20:11EvaluationNotebook[]. You can set it for all notebooks by changing that to$FrontEnd2) These settings are stored in the object's options and persists across sessions. SeeOptions@EvaluationNotebook[]. – rm -rf Mar 28 '14 at 19:49EvaluationNotebook[]to$FrontEndworks. However, my original question was only the quoted part at the beginning (I edited more times), and I am highly puzzled by 1-3, because I could not find any reference to explain the file "KeyEventTranslations.tr" (modifying this file should also be a way). Also, is there a reference that explains what the things likeReturnKeyDownandHandleShiftReturnmean in 4? – renphysics Mar 28 '14 at 22:03