Emacs: Init File Tutorial
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:
Save it at
On linux and Mac, by default, emacs look for init file at the following filepath, in order:
~/.emacs.d/init.el(this is modern, preferred, since ~2010)
XDG_CONFIG_HOMEenvironment variable, supported since emacs 27.1, released in 2020.)
On Microsoft Windows:
It's ok to delete your init file and start over.
- 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.