In this article, we walk through where your Emacs configuration file lives and how to open it, how the init file works behind the scenes, and a handful of starter settings that most writers find useful right away. We also look at how to reload your configuration without restarting Emacs and how to keep your init file organized as it grows. And it will grow! Let’s get into it.
Also, I have a starter config on GitHub you can try to get some instant Emacs juju in your editor.
Table of Contents
Your First Configuration File
Emacs stores its settings in a plain text file. On most systems, that file lives at:
~/.emacs.d/init.el
(The tilde (~) is shorthand for your home directory.) If the .emacs.d folder does not exist, Emacs creates it the first time you run it.
To open your init file from inside Emacs:
C-x C-f ~/.emacs.d/init.el RET
If the file is empty, that is fine. Emacs works perfectly well with an empty init file and sensible defaults.
The ~/.emacs Alternative
Some Emacs users (like yours truly, Mr. Terrific) keep their configuration in a single file called .emacs directly in their home directory:
~/.emacs
This is the older, traditional location. Emacs checks for it first. If it exists, Emacs loads it and skips ~/.emacs.d/init.el entirely.
Both files work the same way. You can use either one. The practical difference is organization: ~/.emacs.d/init.el keeps everything Emacs-related inside one folder, which makes it easier to back up, move to another machine, or delete cleanly. The ~/.emacs file sits loose in your home directory alongside everything else.
If you open Emacs for the first time and find that neither file exists, you can create whichever one you prefer. If both exist, only ~/.emacs will be loaded.
How the Init File Works
Emacs reads your init file every time it starts. Each line is a piece of Emacs Lisp. (Emacs Lisp, or “elisp” is the the language Emacs uses for configuration.) Do not worry about learning the whole language. Most configuration is just copying small snippets and understanding what each one does.
A line that begins with a semicolon (;) is a comment. Emacs ignores it. Use comments to leave yourself notes:
;; This is a comment. Emacs will not evaluate this line.
Some Useful Starter Settings
Here are settings that most writers find helpful. You can add any of these to your init file:
Turn off the startup screen
(setq inhibit-startup-screen t)
Disable the toolbar
The graphical toolbar takes up space without adding much for keyboard users.
(tool-bar-mode -1)
Wrap long lines
Without this, long lines extend past the edge of the window and require horizontal scrolling.
(global-visual-line-mode t)
Enable line numbers
(global-display-line-numbers-mode t)
Show matching parentheses
(show-paren-mode t)
Set a default font
Replace "Monospace-14" with the name and size of any font installed on your system.
(set-face-attribute 'default nil :font "Times New Roman")
Reloading Your Configuration
You do not need to restart Emacs every time you change the init file. To reload it immediately:
M-x eval-buffer RET
Or you can restart Emacs to start fresh with your new settings.
Keeping Things Tidy
As your configuration grows, it helps to group related settings under comment headings:
;; --- Appearance --- (tool-bar-mode -1) (global-visual-line-mode t) ;; --- Writing --- (global-display-line-numbers-mode t)
A well-organized init file is easy to read and easy to change. Start small, add settings only when you need them, and your configuration will grow naturally alongside your workflow.
What Comes Next
Once your init file is in place, the next step is installing packages that extend Emacs with new features. The guide on package management covers how to do this.