Emacs Tips
I like this editor; I thought it might be useful to have a place to share some things I’ve learned. This article is a collection of those things: lessons, appreciations, techniques.
If you are a professional writer – i.e., if someone else is getting paid to worry about how your words are formatted and printed – Emacs outshines all other editing software in approximately the same way that the noonday sun does the stars. It is not just bigger and brighter; it simply makes everything else vanish.
- Neal Stephenson, In the Beginning…
Intro
Others that I’ve spoken with seem to view the software as antiquated, a relic from a past era. At the time of this writing, it’s 33 years old. Compared to most web dev tooling, that is eons. I’ve found myself increasingly appreciative of software that has withstood the test of time. I like new features just as much as the next person, but there is something profoundly inspiring about system designs that survive.
At the time of this writing, I use the spacemacs distribution. For a beginner coming from vim, it eased the transition. I could continue using the familiar vim-keybinds while also exposing myself to emacs. In retrospect, it would have been a better idea to skip vim keybinds altogether, emacs keybinds are really in their own mental space and much more convalescent with the rest of the editor than the more rationally
-mapped vi set. The eybinds were quick to pick up and they tie together with the other features and structure of emacs. That would be my advice to someone considering making the switch: go all-in.
I’m assembling a list of things that I feel set it apart from the rest of the editor crowd. I’d like to update this with examples. I plan to extend the sections into their own articles and have this slowly become a ‘hub’. I’m using the Arch Wiki as a role model. Pull requests, suggestions and critique welcome.
Kill-ring
A [linked-list] that serves as a ‘cut/delete history’. When you delete a chunk of text in emacs it gets placed into a node on this linked list that can be cycled through & retrieved on demand. You can also write this linked list to a buffer. This means anything you ‘cut’ is stored in a separate buffer for easy retrival. It’s like having an infinitely sized cut and paste buffer.
Accessed with M-y
.
Undo tree
Infinite undo history. Multiple undo histories. Visualized in plain text. anecdote: I was using evilmode’s version of undo, which caused some pain, as it would erase blocks of typed text. I was thus under the impression that this was how emac’s undo operated, and was the object of some vocal criticism ex myself. Let it be known that I rescind all previous comments and that acknowledge emacs undo is the most sensible, powerful, and versatile undo operation, across the board.
Keybinds
a sore point for people, especially those coming from vim. so many keybinds! how could you possibly learn them all?? especially when vims’ layout is so systematic? Turns out there are only so many actions that one needs to perform on a regular basis: navigation, undo/redo, and cut/copy/paste. Learning these basics takes an afternoon to commit to memory and a month to nail down. It’s essential to remap ctrl to capslock however.
Packages
- Useful packages I’ve encountered, thanks mostly to them being preenabled in spacemacs.
Org Mode
- In-line LaTeX.
- export to any format: Markdown, HTML, PDF
- Source blocks allow you to run code from any language and output results inside of your notes.
Tramp
- remote into a server, treating it as though it was another directory on your computer.
YASnippet
- create preset blocks of code, for, functions, headers, markup, design patterns, latex presets.
Dired
- browse directories as though they were a buffer. this gives you the power of elisp functions (which are designed to act on buffers) such as copy/paste or opening a git repository from.