In the comments we established that the problem wasn't the code shown in the question:
(add-hook 'magit-status-mode-hook
(lambda ()
(local-set-key (kbd "<C-return>") 'magit-diff-visit-file-other-window)))
The problem was the use of this pattern:
(add-hook 'HOOK (lambda ...))
When that pattern is used, updating the code of that (lambda...)
function necessitates explicitly removing the original/bad lambda from the hook variable before adding a new updated version -- otherwise both functions will be called when the hook runs.
So the problem was that an earlier attempt (with a bad key binding syntax) was still being executed.
Inspecting C-hv magit-status-mode-hook
showed that the old lambda was still present.
The better pattern is:
(add-hook 'magit-status-mode-hook 'my-magit-status-mode-hook)
(defun my-magit-status-mode-hook ()
"Custom `magit-status-mode' behaviours."
(local-set-key (kbd "<C-return>") 'magit-diff-visit-file-other-window))
As the named function can subsequently be updated without also needing to touch the hook variable.
(local-set-key (kbd "C-<return>") #'magit-diff-visit-file-other-window)
works fine for me. What happens when you try that?[C-return]
):(kbd "C-<return>")
and(kbd "<C-return>")
.<return>
? What doesC-h k
tell you when you hit the Return key?(kbd "C-return")
(i.e., no<
at all), is it possible you have that expression somewhere else in your config?