Description
Emacs is a text editor that is hailed for its ability to be customized and many people use it for their agenda, RSS feeds, code editing, and more. By extending the base packages, vim keybindings could be enabled, LSPs can be configured, etc.
Quickstart
I started with Spacemacs which has 200+ packages already configured. This instantly adds lots of keybinds and functionality to emacs, and you’ll have to decide if it’s worth using.
Building a configuration from scratch (instead of using a distro like Spacemacs) is often recommended for beginners to better understand what’s happening under the hood.
Terms
- Projects - Just a folder.
- Layers - A set of configurations that can be enabled/disabled to bring packages together.
- Modes - There are major and minor modes. Simply changes how text input affects the buffer.
- Packages - Extending the base functionality of emacs.
Spacemacs Keybind Reference
Note
As you press keys, watch the menu that appears at the bottom of the screen to find more useful keybinds.
Keybind | Description |
---|---|
<Space> ? | Opens all keybindings |
<Space> <Space> | Opens emacs command menu |
, | Opens the major chord menu |
<Space> f s | Save file |
<Space> f t | Open file tree |
<Space> f e d | Open emacs dotfile |
<Space> f e R | Reload emacs config |
<Space> p f | Find file in project (fuzzy) |
<Space> j = | Auto-format code |
<Space> j j | Jump anywhere |
<Space> w 2 | Split into a 2 window layout |
<Space> w <Tab> | Navigate to next window |
<Space> b b | List all buffers |
<Space> b x | Close current buffer and window |
<Space> T s | Switch themes |
<Space> s s | Search file |
<Space> q q | Kill emacs |
<Ctrl>+c <Ctrl>+p a | Add project to workspace |
<Ctrl>+c <Ctrl>+p d | Drop project from workspace |
<Space> / | Search project (live grep) |
<Space> g s | Open Magit (git) panel |
<Ctrl>+n | Select next occurance |
<Ctrl>+h i | Opens the emacs instruction manual |
As you combine these with vim/emacs keybinds, everything just becomes more efficient.
Performance
Spacemacs and the OCaml layer added ~3s to my emacs startup time. Coming from neovim, this was unacceptable and that’s when I learned to run emacs as a daemon.
systemctl --user enable --now emacs
This command added emacs to my startup services. The idea is that we’ll leave emacs running all the time and connect with a client which is installed as “Emacs (Client)” on my machine.
Instead of cold starting emacs, it will now have a daemon to instantly attach to.
Org Mode
There’s a rabbit hole called org mode which I encourage you to at least consider.
It’s useful for keeping an agenda and creating todos. GDQuest has a solid intro video here.