Vimmer tries Emacs

2024-04-24 Wed 22:34 by Nathan Dawit Chane

Table of Contents

Preface

I love vim. I've been using it for years, and Vi is practically engrained into my muscle memory. Much of my workflow consists of switching to and from vim within a tmux session.

I also love the unix philosophy. Specifically, the process of piping together commands to get what I want. Sometimes, I don't even need to do that within vim. :'<,'>!<some-command> usually does the trick.

My familiarity (and comfort) with this environment is great when I'm working on my not-so-blazingly-fast laptop, and even better on high end vpss'. All the tools I know and love are essentially right there.

However, during all these years of being enamored with my text editor, I was always curious about Emacs. I think this is mostly due to my love for lisp languages, as you can't seem to find one introductory article about a lisp without a mention of Emacs.

I have tried Emacs a couple of times in the past, but it's only recently that I really got into it. The following is a collection of my disorganized thoughts and retelling of my experiences with Emacs as a Vim refugee.

First impressions

I can't recall exactly when I first ran Emacs. It was probably when I first learned about it through a Lisp tutorial or something, but I'm not entirely sure. What I do remember is my first experience with it.

Biting

After installing Emacs and running the emacs command for the first time, I was met with what seemed like 2 seconds of nothing. Just as I was about to ^C^C^C^C^C, A blindingly white window presented itself. As I regained my vision, I started to make out the Emacs logo, followed by a wall of text all under a toolbar that looked like it was from the 90's. Needless to say, I was not appetized.

I decided to go through the tutorial as suggested by one of the lines in said wall of text. C-this to do this, M-that to do that. This was not vim. Windows are frames, and panes are windows. There are buffers, and there are mini-buffers which are basically buffers, but different. There are modes, major ones and minor ones. They each bring their own keybinds and functionality to the buffer. This was not vim.

I didn't like Emacs. As I pushed through while trying to do my day to day activities, I struggled with my muscle memory, constantly hitting the escape key, and messing up even the simplest C-n, and C-p keys. I had the expectation to grok this editor in a couple days when I came into it, but I realized soon that that was a pipe dream.

It wasn't long before I closed Emacs and decided to put it off for another day. A day where I have more patience and bravery.

Itching

I continued to live my life, forgetting about Emacs for a while. However, there was a lot more of it in my online feed than there was before. It was in HN, Lobsters, Reddit, etc… and everytime I came across it, I learned something new about it. People wrote about how it's their operating system, their assistant, their kitchen sink and toolbox. My perception of it as a text editor began shifting, and I started getting an itch. I understood that I was holding it wrong, and that I should view Emacs not just as an editor that happens to do some other stuff, but rather an app that does some stuff, that happens to have an editor.

With this newfound perspective, I decided to try again. This time with a lot of planning beforehand. I wanted to know what I as getting into so as not to be surprised and thrown off. I began researching about how to approach my new Emacs experience. I started off by looking at best-practices and must have plugins.

I found out about evil-mode in one of those "Must have plugins for Emacs in <current-year>" articles and I was excited. Vim keybindings in Emacs! What more could one ask for. It's going in the list.

I also learned about Doom Emacs, and Spacemacs. I was never a fan of these batteries included distros. I found they did too much, and complicated things. I didn't like using them. Not in Vim, not in Linux. Therefore, not in Emacs. Not going in the list.

I heard that people write their emacs config in Org files. In turn, I learned about Org mode. It seemed interesting, and the idea of organizing a config file in a document like structure was enticing. It's going in the list.

A lot more followed once I learned about Org mode, i.e, Org agenda, Org roam, and friends. They seemed useful. They're going in the list.

There were a bunch of other little plugins here and there like which-key, ivy, etc…. They all went in the list.

Could this be it?

With a plan formed, I re-installed Emacs, and began writing my config file. I followed tutorials on setting up an org config file. Once I had done that, I began learning how to use and configure Org mode. As I did that, I also began filling up my config file with the afromentioned plugins.

I added evil mode, and instantly felt at ease. All those familiar keybinds made Emacs feel way less scary. I continued to fill up my config file with these new bindings in hand.

I configured Org mode with org-bullets, org-indent-mode, and org-babel. I made great use of descriptive paragraphs for each installed package and configured option. It was all going very well.

However, there was a problem. I understood none of it. I copy pasted everything, and barely skimmed through the descriptions of what each line did. The more complicated something was, the less I made an effort to understand it.

At the time, I just thought "Yea, I don't care. Just give me my plugins", but that was a mistake. I found myself, a couple days later, with an editor that I barely knew how it worked.

Trouble in paradise

Things were bad. The *Warnings* buffer constantly presented itself during startup and whenever I did anything ambitious, like opening a new file (daring, I know). I had my Vim bindings, but I could barely navigate the array of windows I had open at any given moment. At times, I just let the *Warnings* buffer sit there because I couldn't be bothered to close it.

I constantly felt like a second class citizen with my Vim bindings. Whenever I installed a package, I had to go through the process of rebinding to evil keys if the plugin wasn't supported by evil-mode or vice-versa. Sometimes, I would end up in a buffer without evil-mode (especially when I broke something in my config, which I often did), and I would need to use the basic emacs keys to navigate out of it.

I barely understood Emacs lisp, and just Emacs in general. It seemed like I was trying to blindly turn it into a Vim, without understanding how it worked at all.

Since I spent a lot of time on this config, I was constantly trying to convince myself that I liked it. The truth was I hated it. I couldn't do the most menial of tasks, and had gained nothing in switching to it. I had this gigantic config file with a ton of plugins, and knew how to use none of them.

I decided to ditch Emacs once again.

What now?

I'm the kind to tinker and hack on a thing all day. I don't necessarily take pride in being excited by a bunch of pixels on a screen organizing themselves to form text, but my best weekends are those ones when I'm spending hours at a time figuring a piece of software out, by tweaking and playing with it. Whether it be a text editor, an operating system, a programming language, or even a library, anything that I can explore tends to give me joy.

And so, leaving Emacs like this, I somewhat felt sad. It's a piece of software that was supposed to give me the most joy, but it left me defeated, confused, and lost.

Temporary farewell

For the longest time, I forgot, and ignored Emacs. Meanwhile, I adopted Vi more, applying it to any interface I could find ranging from shells, and TUI programs, to web browsers. I began to think of it as the One True Interface. Programs are supposed to be ran in shells, piped to other programs that did the same, and any navigation and text editing needed to be done in Vi.

Although I forgot about Emacs for the most part, any mention of it would bring up feelings of lost potential. A "something that could've been" feeling that I usually just shake off. It wasn't a very strong feeling, but it was constant enought that I didn't completely forget about the existence of Emacs as a piece of software.

Lisp and SICP

Meanwhile, my intersts in other things were developing. I'm young, and fairly inexperienced, and had an eagerness to learn. Eventually, I decided to pick up the book Crafting Interpreters. I read the first couple chapters and realized I didn't totally enjoy writing the programming language in the book with the programming language recommended in the book. I still wanted to write an interpreter though, so I looked for alternatives and found SICP.

SICP re-ignited a love for Lisp within me that didn't fully get to shine earlier on. I devoured SICP with my regular old vim setup with Conjure for interactive lisp (in this case scheme) evaluation. I had a ton of fun learning, and decided to implement my own made up lisp-like language in Rust.

I had fun implementing my langauge (albeit embarassingly poorly), and I learnt a lot in the process. It also made me understand lisps better which increased my love for them further. At this point, I almost always had a scheme repl open at any point in time, and it was usually not the same implementation as the one before as I was playing around with all kinds of them. I was in the zone of learning and discovery. I felt at home.

However, as you might have guessed, there was constantly an elephant in the room. A looming shadow in a peculiar shape and arrangement that resembled a string of latin alphabetic characters which spelled out "EMACS". Yes, in every book, every blog post, every article, every youtube video and every alleyway I happen to find myself in, it was there, written boldly, and recommended highly.

I was perfectly fine with my setup when interacting with lisps, but there was that familiar sense of being a second-class citizen when using Vim, and it showed itself more when using the less popular schemes.

I got the itch, yet again.

Third time's the charm

After clearing out old config files, I re-installed Emacs. This time, I had 0 expectations. I had the goal of doing lisp development with it, and maybe a little bit of rust on the side, but I had 0 expectations of my skill-level with it after a period of time.

As soon as it installed, I booted it and went through with the tutorial as a refresher. The keybindings were a struggle, however I made an active decision to remove Vi from my life. That meant switching from qutebrowser to firefox, and unsetting the vim-bindings from my fish config. I got rid of any program or configuration that might lead me to relapse to Vi.

I also set out to make use of Emacs for only the things I needed. That meant, no more org-agenda, org-bullets or org-babble. I also made the decisison to only do things I completely understood, which meant I wouldn't write my configs in Org, and I took the time to learn Elisp to some extent.

After about 6 hours of getting used to the keybindings, and installing packages (which was easier after v29 because of treesitter, eglot and friends shipping by default), I was left with a very small and digestible configuration. All that was included was a theme (gruvbox), vertico, marginalia, and rust-ts-mode.

With this configuration, I spent the next few days learning Emacs via built in help functions and only rarely reached out to duckduckgo and stack overflow. I tried to do everything I needed to do on my computer in Emacs, but without overwhelming myself. I did basic coding, and git in Emacs to naturally build muscle memory, but when it came to things like Email I used apps I was already familiar with. I fell back to my familiar terminal enviroment when things got intense, like the time I messed up the state of a git repository during a rebase. I ensured I only learned what I needed to learn as I went, and I kept my list of packages to a minimum so as to not rely on them.

Days went by, and I got better. I started getting "the Emacs way" of doing things. It felt easier to navigate the array of windows I had open at a time, and I started to discover features naturally. The keybinds started flowing more too. a little C-x r t <RET> here, a little C-S-<backspace> there. I had little bit of Vim-isms sometimes, but they went away very soon.

Most importantly, I began making good use of Emacs. I didn't have an org-agenda workflow, but all my projects had an associated README.org file. Magit became second nature, and project.el started becoming my favorite thing. There's just something about project-kill-buffers that makes me feel so at ease. Needless to say, I had emacs --daemon running 24/7.

As I grew more confident, I gave myself the right to install more packages, and tweak more options. I spent more time familiarzing myself with more keybindings, and made my own. I had the ability to skim through someone else's .el file and figure out what was going on (although, most people document their files generously around here).

Clicking

Without the burden of expectation, and misguided ambitions, I was able to naturally come to understand Emacs, rather than trying force "progress". I didn't rush to add all the bells and whistles, I took small steps and made very mindful changes to my configuration, which ,now that I think about it, is the same way I learnt vim. This all led me to have a better understanding and perspective on Emacs.

I realized I made the mistake of treating Emacs like an old glorified text editor. The answer was really right under my nose. To make comparisons, Emacs is not a Vim, Emacs is the tmux session you run Vim in. More literally, at the risk of re-stating myself, Emacs is not a text editor that happens to do a bunch of other things, Emacs is an app that does a bunch of things, which includes editing text.

Really, like how most people describe it, Emacs is just a Lisp evaluator that you use to interact with your computer. A shell, but instead of POSIX sh, it evaluated lisp, and instead of a terminal interface, it used a GUI (and maybe sometimes a TUI if that's your thing).

To me, it was not useful to try to equate Emacs to tools I've used before. It only did me harm to try to bend it into what I was used to, when it just wasn't. It's different, and after coming to terms with that, I was able to enjoy it.


(defun goodbye ()
  (message "bye bye"))