Here’s how to set up your Emacs initialization file on Windows.

First, the Emacs InitFile can be called .emacs or _emacs. Some people may find it’s easier to work with _emacs on Windows.

The Emacs Windows FAQ includes some instructions.

You can take three paths:

Note that you can always edit the official Emacs startup file by typing C-x C-f ~/.emacs. This will get translated to one of the locations supported above. After the file is loaded, to see what the true path is type: C-h v buffer-file-name RET

HOME setting

Note that your HOME environment variable might not be set on your system, but GNU Emacs 22 appears to set this variable in its wrapper script. Thus, the InitFile is often in a location like c:\Documents and Settings\user\Application Data\.emacs.

registry settings

In the registry, set:

Or, if you want changes system wide:

environment variable

If you take the environment variable path, you’ll need to figure out how to do it for your particular system. There are some notes on setting Windows environment variables out on the web.

If you have Windows NT or XP, you can set the HOME environment variable as follows:

  1. Right-click My Computer.
  2. Choose Properties.
  3. Choose the Advanced panel (tab).
  4. Click Environment Variables.
  5. Under User Variables, click New and create a variable named HOME that points to where you want your home folder.

The cleanest option I’ve found is to soft link my version-controlled .emacs file in the default emacs.exe HOME directory:

cmd /c "mklink C:\Users\andrew\AppData\Roaming\.emacs C:\Users\andrew\src\dotfiles\.emacs"

(Use M-: (getenv "HOME") RET to get your HOME directory as seen by Emacs.)


Windows NT and up set a UserProfile environment variable that’s equivalent to HOME. This might be useful somehow, though this whole issue is moot with Emacs 22 and up, if it really does set HOME for you.

CategoryWThirtyTwo CategoryDotEmacs