Your init file contains personal EmacsLisp code that you want to execute when you start Emacs.

See the Emacs manual (‘C-h r’), node Init File.

If you do not know where your init file is located or you do not have one and want to create it, then just open it for editing in Emacs:

   C-x C-f ~/.emacs.d/init.el RET

When you add Emacs Lisp code to your init file, it is not evaluated until you restart Emacs. Rather than restarting Emacs, you can use ‘M-x eval-buffer’ to evaluate everything, or ‘M-x eval-region’ to evaluate a part you select, or just ‘C-x C-e’ (command ‘eval-last-sexp’) to evaluate the Emacs Lisp expression immediately before your cursor. See EvaluatingExpressions.

If it seems like your init file is not being read, type ‘C-h e’ to see if there is a chance there was a problem with it loading. See DebugFileLoading for more troubleshooting tips.

It’s often better to break up a lengthy init file into a number of EmacsLisp libraries and a small, top-level init file that loads those libraries, especially if you define commands and other functions. Some of the init files posted on EmacsWiki are organized in this way, as a set of library files.

For info about how to load an EmacsLisp file automatically when you start Emacs, see InstallingPackages.

You can also have a separate CustomFile reserved strictly for customizations recorded by Customize.

Start Emacs with a specific init file:

   emacs -q -l ~/my-init-file.el

For more information about init files and custom files (Emacs 22 or later):

C-h r i init-file RET or M-: (info "(emacs) Init File")
M-: (info "(emacs) Saving Customizations")
M-: (info "(elisp) Init File")

See the pages in CategoryDotEmacs for configuration suggestions and tips.

CategoryHelp CategoryDotEmacs CategoryGlossary