Level Up Your Editing Game: A Beginner’s Guide to Doom Emacs
So, you’ve heard whispers of a legendary text editor, one that can be molded to fit your every need, a veritable Swiss Army knife for text: Emacs. But maybe the thought of diving into its vast configuration has you feeling a bit overwhelmed. Fear not, intrepid coder and writer! Enter Doom Emacs, a fantastic distribution of GNU Emacs that provides a powerful and user-friendly experience right out of the box. If you’re familiar with Vim, even better, as Doom Emacs comes with Evil mode enabled by default, bringing those beloved Vim keybindings to the Emacs ecosystem.
This isn’t just another text editor; it’s more like an operating system within your operating system. Let’s explore how you can get started with Doom Emacs and unlock its potential.
Getting Your Hands on Doom Emacs
Before we dive in, let’s make sure you have the necessary foundations laid. Doom Emacs has a few dependencies you’ll need to install:
- Git 2.23+: Essential for cloning the Doom Emacs repository.
- Emacs 26.1+ (27.x recommended): Doom Emacs is built on top of GNU Emacs, so you’ll need it installed first.
- ripgrep 11.0+: A fast and efficient search tool.
- GNU Find: A standard utility for finding files.
- (Optional) fd 7.3.0+: A more user-friendly alternative to find that can improve performance for file indexing.
On a Linux system, you can typically install these dependencies using your distribution’s package manager. For example, on an Arch-based system, you might use sudo pacman -S emacs git ripgrep fd find. Ubuntu users might need to install git separately with sudo apt install git before installing emacs and other dependencies.
Once you have the prerequisites, installing Doom Emacs is a breeze:
- Clone the repository: Open your terminal and run: git clone –depth 1 https://github.com/hlissner/doom-emacs ~/.emacs.d This command clones the Doom Emacs repository into the ~/.emacs.d directory.
- Run the installer: Navigate to the Doom Emacs directory and execute the install script: ~/.emacs.d/bin/doom install Alternatively, if you’ve added ~/.emacs.d/bin to your system’s PATH (which is highly recommended), you can simply run doom install from anywhere in your terminal. You can add this to your .bashrc or .zshrc file: export PATH="$HOME/.emacs.d/bin:$PATH"
- Follow the on-screen instructions. The installer might ask you about generating an environment variable file (answering yes is generally safe, especially on macOS), and it will likely prompt you to download and install icon fonts (answering yes is recommended for the best visual experience).
- After the installation completes, it’s a good practice to run doom doctor to diagnose any common issues with your system or configuration.
Understanding the Configuration Trio
Doom Emacs organizes its configuration into three key files located in your DOOMDIR. Your DOOMDIR is typically located at ~/.config/doom or ~/.doom.d (Doom will only recognize one of these). Understanding these files is crucial for customizing your Doom Emacs experience:
- init.el: This is where you’ll find your doom! block. This block controls which Doom modules are enabled and their loading order. Modules bundle together packages and configurations for specific functionalities like programming languages, version control, or user interface enhancements. To enable or disable a module, simply uncomment or comment out its line within the doom! block. Remember to run doom sync after modifying this file for the changes to take effect.
- config.el: This is your primary configuration file. 99.99% of your private configurations should go here. This file is evaluated after all modules have loaded. Here, you can customize themes (set-q doom-theme ‘doom-pill-night), fonts (set-q doom-font (font-spec :family “Mononoki Nerd Font” :size 15)), and various settings for your enabled modules and packages. While you might not know Emacs Lisp (the language used for Emacs configuration) right away, you can often find snippets of code online to achieve your desired customizations. Changes in config.el usually don’t require a full doom sync, but sometimes a restart (doom restart or space h r r from within Emacs) might be necessary.
- packages.el: This file is dedicated to managing external packages (those not included in the default Doom modules). Doom Emacs doesn’t use the built-in package.el for this. To install a package, add a package! declaration followed by the package name. For example, to install evil-tutor (a great way to learn Evil mode keybindings), you would add: (package! evil-tutor) Crucially, new packages won’t be installed until you run doom sync. Do not try to configure packages directly in packages.el using use-package! or after! as this file is read in an isolated environment. Package configurations belong in config.el.
Navigating Your Doom Emacs Experience
Once Doom Emacs is installed and you’ve grasped the basics of the configuration files, it’s time to start using it!
- Launching Doom Emacs: You can launch Doom Emacs by simply typing emacs in your terminal. For a faster startup, especially if you plan to use Emacs frequently, you can set up an Emacs server and connect to it using emacsclient. You can configure your system to start the Emacs daemon automatically on login and create an alias for emacsclient -ca emacs to emacs for convenient launching.
- Basic Keybindings: Since Doom Emacs defaults to Evil mode, you’ll feel right at home if you’re a Vim user. The familiar hjkl for navigation, i for insert mode, Esc to return to normal mode, :wq to save and quit, and many other Vim commands work as expected.
- Doom Emacs Leader Key: Doom Emacs utilizes space as its leader key for many of its custom keybindings. This makes accessing common actions quick and easy. Some essential leader key combinations to get you started: space f f or space . (find file): Opens a file explorer to locate and open files. space f r (find recent files): Shows a list of recently opened files for quick access. space b p (buffer previous): Switches to the previously active buffer. space b n (buffer next): Switches to the next active buffer. space b k (buffer kill): Closes the current buffer. space b i (Ibuffer): Opens a dedicated buffer manager to see and manage all open buffers. space w v (window vertical split): Creates a new vertical window. space w s (window horizontal split): Creates a new horizontal window. space w w (window switch): Switches the cursor to the next window. space w c (window close): Closes the current window. space h r r (Doom restart): Restarts the Doom Emacs server and reloads your configuration.
- File Management: Besides find file, Doom Emacs also offers deer (directory editor), a powerful file manager within Emacs. You can access it by typing space . and then pressing enter without specifying a file, or by using meta x deer.
Beyond the Basics: Unleashing the Power
Doom Emacs, and Emacs in general, offer a vast array of features. Here’s a glimpse of what awaits you:
- Org-mode: A built-in powerhouse for outlining, note-taking, to-do lists, time management, and even literate programming. With Org-mode, you can structure your thoughts, create interactive documents, and manage your life, all within Emacs. You can create headings with asterisks (*), fold and unfold sections with tab and shift-tab, and even create to-do items by typing TODO in all caps.
- Terminals within Emacs: Doom Emacs allows you to have fully functional terminal emulators directly within Emacs, such as vterm and eshell. This allows you to seamlessly switch between editing files and running commands without leaving the Emacs environment.
- Extensibility: The true strength of Emacs lies in its extensibility through Emacs Lisp. While you don’t need to learn it immediately, knowing that you can customize virtually every aspect of your editor and add countless packages from the vibrant Emacs community is incredibly empowering.
Final Thoughts
Getting started with Doom Emacs might seem like a big leap, but with its sensible defaults and the familiar Evil mode, it offers a much smoother entry point into the world of Emacs. By understanding the three core configuration files and mastering a few essential keybindings, you’ll quickly find yourself navigating and customizing your editor with confidence.
Embrace the journey, explore the modules and packages, and don’t be afraid to tinker with your configuration. Doom Emacs is a tool designed to evolve with your needs, ultimately becoming a powerful and personalized environment that can significantly enhance your productivity. So, go ahead, take the plunge, and level up your editing game!