views:

2726

answers:

8

I tried looking for the .emacs file for my Windows install for Emacs but could not find it. Does it have the same filename under Windows as in Unix? Do I have to create it myself? If so, under what specific directory does it go?

+12  A: 

Copy'n'paste from the emacs FAQ: http://www.gnu.org/software/emacs/windows/

On Windows, the .emacs file may be called _emacs for backward compatibility with DOS and FAT filesystems where filenames could not start with a dot. Some users prefer to continue using such a name, because Explorer cannot create a file with a name starting with a dot, even though the filesystem and most other programs can handle it. In Emacs 22 and later, the init file may also be called .emacs.d/init.el. Many of the other files that are created by lisp packages are now stored in the .emacs.d directory too, so this keeps all your Emacs related files in one place.

All the files mentioned above should go in your HOME directory. The HOME directory is determined by following the steps below:

  1. If the environment variable HOME is set, use the directory it indicates.
  2. If the registry entry HKCU\SOFTWARE\GNU\Emacs\HOME is set, use the directory it indicates.
  3. If the registry entry HKLM\SOFTWARE\GNU\Emacs\HOME is set, use the directory it indicates. Not recommended, as it results in users sharing the same HOME directory.
  4. If C:.emacs exists, then use C:/. This is for backward compatibility, as previous versions defaulted to C:/ if HOME was not set.
  5. Use the user's AppData directory, usually a directory called Application Data under the user's profile directory, the location of which varies according to Windows version and whether the computer is part of a domain.

Within Emacs, <~> at the beginning of a file name is expanded to your HOME directory, so you can always find your .emacs file with C-x C-f ~/.emacs.

Node
A: 

On my Vista box it's in C:\Users\<USER>\AppData\Roaming\

Alexander Kojevnikov
A: 

On XP it's:

C:\Documents and Settings\yourusernamehere\Application Data\

polarbear
+9  A: 

Open the file like this in Emacs for Windows:

C-x C-f ~/.emacs

More information in the Emacs Wiki

sverrejoh
+2  A: 

It should be stored in the variable user-init-file.

use C-H v user-init-file RET

to check

kanja
A: 

I've found that Emacs 22 will occasionally open either "C:\Documents and Settings\username\Application Data\.emacs", or just "C:\Documents and Settings\username\.emacs" on my XP machine. I haven't found an explanation for why it occasionally changes it's mind.

~ will always point to whatever the current instance of emacs thinks is HOME, but kanja's tip (C-h v user-init-file) will always tell you what ~/.emacs actually maps to.

remicles2
A: 

On versions of emacs on windows above 22, it seems to have moved to

~/.emacs.d/init.el

, ~ being the value of your environment variable HOME (see Control Panel -> System -> Advanced -> Environment variables).

The file itself might not exist, in that case just create it.

Gauthier
A: 

on emacs 23 and Windows7 only works if you set:

HKCU\SOFTWARE\GNU\Emacs\HOME

_ex_