Very similar to this question, particularly the second part to this answer:

From the diff view of a specific commit, is there a way to jump to the current+editable version of a modified file? If I press RET on the file, Magit takes me to a read-only view of that file from that commit; is there a simple way to instead jump to the current version of that file so I can edit it?

(My current workflow is to use find-file-in-project to load the file but it'd be so much faster if I could directly navigate to it via Magit.)

  • 1
    The HEAD version of a modified file is the file as it was at the most recent commit. That's not the same thing as the current/editable file (which will contain the modifications). Which do you want?
    – phils
    Jan 19 '19 at 10:02
  • Good point; I want current/editable file. (Corrected question's working to make more clear.) Jan 21 '19 at 18:55
  • 1
    I'm actually still slightly confused by the question. If you're looking at a commit in Magit then just type C-RET instead of RET on one of the hunks for that file, and Magit will take you to the current file (at maybe the desired position, but interim changes might mess with that). I originally thought you meant you were viewing a revision of a single entire file as it was at the point in time of a given commit (in which case I couldn't see an existing key binding to jump to the current file).
    – phils
    Jan 22 '19 at 20:28
  • @phils Sorry I wasn't more clear in my use case: I talked about pressing RET because that I what I knew, but I was looking for the behavior of C-RET. Thanks for helping me clarify my question. Jan 23 '19 at 19:04

To visit the current version of the file in the working tree press C-RET instead of RET. By the way, the latter takes you to the blob that added the current line when point is on a line beginning with + and to the version that last had that line on a line beginning with -.

  • I did not know that about RET -- that it jumps to the correct blob based on whether point is at + or -. Thank you for including that note! Jan 23 '19 at 19:06

You can achieve the wanted behaviour by typing


Now you just need to replace each shortcut with the corresponding function:

(defun magit-open-current ()
   "Open the current version of a modified file."
   (move-end-of-line nil)

If you want to open the file immediately without confirmation, replace the last line with

   (find-file (ffap-file-at-point)))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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