bajsicki.com/content/blog/I-love-emacs.md

107 lines
7.2 KiB
Markdown
Raw Normal View History

2024-11-18 18:28:17 +01:00
+++
title = "I really, really like Emacs"
publishDate = 2022-10-01T00:00:00+02:00
2024-11-18 20:00:52 +01:00
lastmod = 2024-11-18T20:00:51+01:00
2024-11-18 18:28:17 +01:00
tags = ["orgmode"]
categories = ["emacs", "tech"]
draft = false
meta = true
type = "list"
[menu]
[menu.posts]
weight = 3009
identifier = "i-really-really-like-emacs"
+++
I was taking with a friend a few hours ago and he mentioned that Emacs is intimidating. And yes, it may well appear so.
<!--more-->
But all things considered, that's really not true at all. It's no more difficult to use than GUI programs such as Microsoft Word, or Excel (the latter of which said friend excels at, pun fully intended.)
So let me dispel this uncertainty and doubt about Emacs, and the way it actually feels to use.
First and foremost... it's a keyboard-driven application. For many, that is reason enough to panic, but if you can get past the fear factor... remembering key sequences for functions is really not that different than remembering where to click on the screen in any other piece of software.
Secondly... you don't really have to remember. I have yet to find a function in Emacs that would not have a corresponding command to be ran with `M-x`. But what is `M-x`? It is how most keybindings in Emacs are written.
`M-x` opens the `execute-extended-command` prompt at the bottom of the Emacs window, which lets you look up functions by name. Thankfully they're all quite sane, so if you remember the verb you want to use (e.g. 'transpose', 'kill', 'delete', 'replace'), you can just type it in, and you will be faced with a good bunch of choices to make your life easier.
There are several modifier keys which act much like shift does on your keyboard. Except instead of making Emacs type in different letters and symbols, they call different functions of the software.
For example, `C-t` (that is, holding the control key and pressing `t` on your keyboard) transposes the two letters (and symbols) on either side of your text cursor. Conversely, `M-t` does the same for _words_.
Of course, you don't need to remember this - I don't. Usually I just backspace and fix things if I need to.
But there are bindings which are useful. For example, making a list (note that this is probably only applicable to org-mode, but that's fairly exclusively the mode I use):
```text
- dash, space, type type type... C-return (or C-enter if that's your preference)
- and here we just continue typing in a new bullet
```
And numbered lists work the same. So do headings, which start with `*`. If I want a subheading, I just increase the number of asterisks. _Or_ I can just hold Meta (the Alt key on the keyboard) and use the arrow keys to move that heading or list element around - including making it a subheading, promoting it to a full heading, or moving it up and down the list.
_Note that in the example block, the bullets are displaying as hyphens_ dashes - that is how the actual website is written. It's only later shown in your browser as bullets./
Then there's the wonderful ways in which Emacs handles files.
When you open a file in Emacs, it is loaded into what's called a buffer. It's essentially a separate space in Emacs where that file then lives, until it's closed (or in Emacs parlance, the buffer it's loaded in is killed).
To switch buffers, you just hit `C-x b` and pick from the list. You can have as few, or as many as you wish. There is no real limit to how many files you can open... and they take no screen space unless you choose to see them. No dozens of windows floating around on the screen makes for much easier focus and quicker work.
But what if you want to see more than one file at a time? `C-x 2` splits the view vertically (i.e. one buffer on top of the other), and `C-x 3` splits it horizontally (one on the left, one on the right.)
And when you want to go back to seeing just one buffer... `C-x 0`. That simple.
Of course, you can also look at the same buffer in different places. That's the major reason why I went full-time with Emacs back in 2016. I was writing _a lot_ of copy at the time, and needed a sane way to manage my notes, my references, and make sure the sales letters were internally consistent.
Emacs has been a true godsend to someone who, like me, lives and breathes typing and editing.
But let's talk about one of the things a lot of people get hung up on when it comes to Emacs. The kill-ring, and the most useful of all commands, `C-k`. `C-k` kills (that is, cuts) from your cursor to the end of the line.
```text
In the next line, I'll put the cursor right after THIS word, and press C-k.
In the next line, I'll put the cursor right after THIS
And in the next line I'll press C-y (yank):
word, and press C-k.
```
As you can see, spaces are preserved in the kill-ring.
You can also use `M-y` to choose which previously killed bits to yank from the kill-ring right into your live buffer.
Note that I'm only bringing the `kill-line` function up because we _all obviously know_ about `C-backspace` to kill the last word, and `M-d` to kill the next word after the cursor.
And this isn't getting into even the half of it.
- `C-x C-s` (or, x-then-s while holding down the control key) saves the buffer (file) to your drive.
- `C-x C-f` opens a file in a new buffer (if it's already open, it brings up its buffer).
- `C-x k` opens a menu which lets you select which buffer to kill (close the file).
- `C-g` stops any processes and quits out of any menus you may find yourself in
- `C-space` sets a mark. When you then navigate the file (for instance with your arrow keys), it selects text. No need to hold shift!
- `C-x space` sets a mark for _rectangular_ selection. Ever only want to select the first few characters of each line of text? You easily can!
- `C-w` kills the selected region
- `C-c .` (in org-mode only; and yes, that's a period as the second part), opens a menu to insert an active time-stamp into the document
- `C-s` starts a search in the document
- `M-%` (that's alt-shift-5) lets you do run the query-replace function, to replace any instances of a phrase with something else
- And of course, `C-x C-c` exits (closes) Emacs.
And there's so much more... but that's about 90% of what I use on a daily basis. I don't even code on the regular - all plain text editing.
The bottom line is... Emacs is not at all hard. And it's infinitely customizable, because it's not really a text editor. It's a full interpreter for the Emacs Lisp programming language. You can surf the web, get your email, run project management, store your diary, translate, write, code, read rss feeds, watch videos, run all kinds of code IN IT.
The text editor part is very extensive and well thought out, but it's really not at all difficult to learn. Once you get used to just how comfortable and effortless writing becomes when you take advantage of that polish, it is really difficult to go back to anything else.
Emacs is just the supreme tool for any use-case which requires typing.
There is no alternative that comes even close to how powerful Emacs is.
[Join the FSF.](https://my.fsf.org/join)
PS. If you want a nice, very well polished and 'out-of-the-box' experience with Emacs, give [Doom Emacs](https://github.com/doomemacs/doomemacs) a go. It's really good, very easy to configure, and _fast_. It includes everything you could need to start using it, and be ready to go in minutes.