I've normally used
~/.emacs for my config file, but I've noticed others using
~/.emacs.d/init.el. Are there advantages to the
init.el location? Any disadvantages?
Yes, there are. Quoting lunaryorn on Reddit:
It keeps the
$HOMEdirectory uncluttered, because all of Emacs' files are neatly contained in a single directory. For the same reason, all modern Emacs packages write their caches, histories, etc. into
It makes version control easier, especially if you split your init.el into different files in
~/.emacs.d. You can just commit
init.ellike every other file, and
git clone /my/emacs/config.git ~/.emacs.don a new system gives you all of your Emacs configuration, without having to link a file into
If all you need to set up Emacs the way you like is an init file, it doesn't make a difference if it's
~/.emacs.d/init.el. But it makes sense to create a directory the moment you start splitting your init file, or adding Emacs-related configs, a Cask file for example. Also, it's the place where you'll save the file with abbrev definitions, the file for custom options (
M-x customize), etc.
Keep everything neatly tucked in
Emacs 27 will introduce a new initialisation file
user-emacs-directory, namely at
~/.emacs.d/early-init.el. So a further benefit to using
~/.emacs.d/init.el instead of
user-init-file is that the former will place both initialisation files under the same roof, for consistency.
Until Emacs 27 is released, you can find the documentation for this new feature in the following files of the Emacs source tree: