Emacs: Init File Tutorial

By Xah Lee. Date: . Last updated: .

This page shows you how to set up many preferences in emacs.

The following assume you are using GNU Emacs version 25.1 (released in 2016) or later.

What is Init File

Emacs init file is a file emacs loads when it starts up. It is used to customize emacs.

Emacs init file is also known as “dot emacs file”.

Where is Init File

By default, there is no init file. You have to create the file yourself, and add emacs lisp code to it.

Create a file with this content:

(set-background-color "ivory")

Save it at ~/.emacs.d/init.el

On linux and Mac, by default, emacs look for init file at the following filepath, in order:

On Microsoft Windows:

[see Emacs in Microsoft Windows FAQ]

It's ok to delete your init file and start over.

user-emacs-directory
Variable. This variable stores the init file path once emacs found one. [see Emacs: Show Variable Value]

Start Emacs Without Loading Init File or with Different Init File

Load Modified Init File Without Restarting Emacs

See Evaluate Emacs Lisp Code. Once the code is evaluated, effect are immediate.

Note, some packages, or elisp code, may behave differently when loaded twice. And some code may not work by simply running it by itself (it may assume some other code has been loaded before or after.).

If you have a problem, restart emacs.

Sample Init File

much thanks to jcs. http://irreal.org/blog/

Thanks to Ivan Kozik (http://ludios.org/ivank/) for a tip.

Reference

(info "(elisp) Init File")

ErgoEmacs mascot-s276x226
Buy Xah Emacs Tutorial

Emacs Init Files


Emacs Init

Init Basics

Keys

Font

Text Editing

Completion

File

Restore Things

Backup/AutoSave

Line

Appearance

Misc

Advanced Init Tips

packages