This answer specifically address the question of how/where to find Emacs'
user-init-file
on Microsoft Windows.
HOME and Startup Directories on MS-Windows
Here is the relavent section from the Emacs manual (available via C-h i
)
Emacs > Microsoft Windows > Windows Home
The Windows equivalent of
HOME
is theuser-specific application data directory
. The actual location depends on the Windows version; ...C:\Users\USERNAME\AppData\Roaming
on Windows Vista and later ... If this directory does not exist or cannot be accessed, Emacs falls back toC:\
as the default value of ‘HOME’.
This location is stored in the environment variable that windows
refers to as %APPDATA%
. See this question and
answer on
superuser
You can try to find the location of your user-init-file
by doing C-h v
and
then user-init-file [RET]
. You will see an output similar to
~/.emacs
On Windows this isn't particularly helpful. We can now find out what
Emacs means by ~
doing one of the following:
C-x C-f
> ~
> [backspace]
The echo
area at the bottom of your Emacs screen will expand to show
you what Emacs currently consider to be HOME. (Note that this works on
Windows and according to @NickD doesn't work on GNU/Linux)
OR more generally (quoting from the Emacs manual)
You can always find out what Emacs thinks is your home directory’s location by typing
C-x d ~/ <RET>
. This should present the list of files in the home directory, and show its full name on the first line. Likewise, to visit your init file, typeC-x C-f ~/.emacs <RET>
(assuming the file’s name is.emacs
).
Setting up the init.el
on Windows
Instead of keeping a .emacs
file most emacs users now use an
init.el
file stored in your emacs-user-emacs-directory
. This directory
defaults to ~/.emacs.d
and in your case
%APPDATA%/.emacs.d/
. Assuming you don't already have a .emacs
file
stored in %APPDATA%/
You can now go ahead and create an init.el
file inside the .emacs.d
directory. Put some sample configuration
in your init.el
file and see if Emacs picks it up when you re-start
Emacs. Also see this
this anweranswer on Emacs
Stackexchange.
Happy Hacking :)