Note that RET may or may not visit the current file.
C-hkRET tells us:
<return> runs the command
If the diff shows changes in the worktree, the index, or HEAD,
then visit the actual file. Otherwise, when the diff is about an
older commit or a range, then visit the appropriate blob.
The optional FORCE-WORKTREE means to force visiting the worktree
version of the file. To do this interactively use the command
You can use C-RET to call
From a diff, visit the corresponding file at the appropriate position.
The actual file in the worktree is visited. The positions in the
hunk headers get less useful the "older" the changes are, and
as a result, jumping to the appropriate position gets less
Jumping to the current file is, more often than not, what I want to
do, and so I use the following to swap the meaning of RET
;; Swap the meanings of RET and C-RET on diff hunks.
;; Note that the default RET bindings are [remap magit-visit-thing]
;; in the original keymaps, but I am only concerned with RET here.
;; Note also that in a terminal, C-RET sends C-j.
;; Using the same key formats here as magit-diff.el
(define-key magit-file-section-map [return] 'magit-diff-visit-file-worktree)
(define-key magit-file-section-map [C-return] 'magit-diff-visit-file)
(define-key magit-file-section-map (kbd "C-j") 'magit-diff-visit-file)
(define-key magit-hunk-section-map [return] 'magit-diff-visit-file-worktree)
(define-key magit-hunk-section-map [C-return] 'magit-diff-visit-file)
(define-key magit-hunk-section-map (kbd "C-j") 'magit-diff-visit-file))