Is there a function I can call that opens my init file for editing or returns its path?


2 Answers 2


See the variable user-init-file described in section 38.1.2 The Init File of the Emacs Lisp manual.

Using this variable it is easy to build an interactive command that opens the init file:

(defun my-open-init-file ()
  "Open the init file."
  (find-file user-init-file))

One simple alternative would be to add a bookmark for your init file (bookmark-set, bound to C-x r m by default). Then you can use bookmark-jump (C-x r b) to return to it.

Also, if you enable recentf-mode and use either Helm, or Ido with the ido-use-virtual-buffers mode, then switching to any recent file is as quick as C-x b <filename>. After enabling this and setting recentf-max-saved-items to a nice high value (1000), I practically never even think about whether a file is already open or not -- everything is accessible through a single key binding all the time.

This isn't so helpful if you use Emacs on multiple systems which put the init file in different places, or if you don't edit your init.el frequently (but what kind of Emacs user would that be true of?!?)

  • Thank you for the advice. Yes, the variable named in Constantine's answer allows me to determine where the init file is on different systems. I'll admit that there aren't many possible locations... But it's good to know the variable name!
    – daveloyall
    Nov 7, 2014 at 15:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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