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?
I've normally used
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
One additional advantage: if everything is in
.emacs.d, you can keep your Emacs configuration on Dropbox (or an alternative) and symlink the whole configuration to your home directory. That makes syncing across computers trivial.
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:
Not sure if this really makes a difference in terms of speed, but you can byte-compile your setup more easily if your configuration is in