Emacs in Microsoft Windows FAQ

By Xah Lee. Date: . Last updated: .

Where to download emacs for Windows?

Download Emacs for Windows/Mac

Where is emacs init file on Windows?

[see also Emacs: Init File Tutorial]

On {Windows 10, Windows 8, Windows 7, Windows Vista} , by default, emacs looks at the following directory/file.

$HOMEPATH/AppData/Roaming/.emacs
The .emacs file is old emacs convention, used in 1990s and 2000s.
$HOMEPATH/AppData/Roaming/.emacs.d/init.el
The .emacs.d/init.el is modern convention.

The init file may be byte-compiled. Byte-compiled file names ends in .elc. If a Byte-compiled file exist, emacs will load it instead. [see Emacs: Byte Compile Elisp Files]

If you have the environment variable named HOME, then it's at:

HOME should not be confused with HOMEPATH.

(info "(emacs) Find Init")

How to list environment variables?

  1. Launch PowerShell: press the ❖ Window key, then type powershell.
  2. in PowerShell prompt, type dir env:

Create a Environment Variable HOME

I highly recommend you create a environment variable named HOME. Because the HOME directory is heavily used by emacs from the unix convention.

Set the value of environment variable HOME to the same value as the environment variable HOMEPATH.

In PowerShell, run this:

[Environment]::SetEnvironmentVariable("home", $env:homepath, "User")

[see PowerShell: Set Environment Variable]

Changes to environment variable in registry are not reflected in current PowerShell session. Type exit to exit PowerShell. Start a new process.

Create a Emacs Init File

I recommend you create a emacs init file at

$HOME/.emacs.d/init.el

How to find out if emacs init is loaded?

put this in your Emacs Init File:

(set-background-color "grey")

If emacs starts with new background color, then it's loaded.

How to Start Emacs by Command Line?

Launch PowerShell , then type for example: ~\Downloads\emacs-27.1-x86_64\bin\runemacs

How to start emacs in graphical user interface?

Go to emacs folder, then in the “bin” dir, then click on file runemacs.exe

How to start emacs with default dir at home dir?

Create a Windows shortcut, then set the “Start in” field.

Windows 10 emacs shortcut bXv5F
Windows 10 emacs shortcut

To create a file shortcut:

  1. Hold Alt then drag that runemacs.exe icon to desktop.
  2. In the newly created alias icon, right click to open file properties. Then, in the “Start in” field, enter your home directory.
  3. In the “Target” field, you can add emacs command line options. For example: %home%\apps\emacs-24.1\bin\runemacs.exe -q --load=%home%\ErgoEmacs_dev\init.el --load=%home%\.emacs. Here, i suppress loading init files by -q, but load ErgoEmacs init files, then load my personal init files.

When i type Ctrl+Space, Windows switches me to other language input. What to do?

Disable Windows Control+Space Alt+Space Shortcuts

When i type Ctrl+Alt+s, HP System info came up. How to disable that?

Disable Ctrl+Alt+S Shortcut for HP Support Info

How to run PowerShell or Bash in emacs?

By default, Alt+x shell runs Windows console cmd.exe inside emacs.

You can use eshell.

Setting Environment Variable for Emacs Only

Emacs: Environment Variables in Emacs

Install Linux Tools

Some of emacs's features require unix utilities. The essential ones are these:

There are several ways to get linux tools for Microsoft Windows.

I recomment:

For old school you may try Cygwin Installing Cygwin Tutorial

Alternatively, i recommend not rely on unix {find, grep, diff}, because they are 30 years old technology.

You can easily use PowerShell for unix find/grep/diff. [see PowerShell Tutorial]

For find/replace/grep needs within emacs, try Emacs: Find Replace in Pure Elisp, xah-find.el

XahTV 2021-03-02. Q and A. Emacs Init for Windows. Why Interest in Math?
ErgoEmacs mascot-s276x226
Buy Xah Emacs Tutorial

Emacs Tutorial

Quick Start

Manage Windows

File

Buffer

Find Replace

Copy/Paste

Unicode

Whitespace

Rectangle Edit

Line Wrap

Shell

View Special File

Editing Brackets

Org Mode

HTML

Emacs Efficiency

Misc