Ramón Calvo's picture
Ramón Calvo
Robotics Engineer

Quick guide for coming to the dark side (a.k.a. painless Vim to Emacs transition)

Published on 02 Dec 2020

Ranting

Being an avid (neo)vim user for the last two years and a half, I couldn’t envision myself using anything else. Vim has everything: fast start-up times, sane keybindings, an infinite amount of plugins, … But as everything in life it doesn’t come without flaws. The vim community is already splitting, as neovim slowly diverges from its predecessor. Because of the Lua scripting present in neovim, new plugins may not be compatible with original vim. As much as Vim is trying to catch up with NeoVim, I don’t see Bram Moolenaar introducing Lua scripting inside Vim.

But, although Vim is chasing NeoVim, the latter is really chasing Emacs. The ground breaking features once introduced in NeoVim such as async, terminal emulation and scripting (through Lua) were already features of Emacs. And Emacs still offers unique utilities such as magit, org-mode or TRAMP, and other excellent quality packages of which we will talk later.

Emacs is also constantly evolving on its own, bringing exciting new features to every new release. The experimental feature (at the time of writing) that made me give Emacs a second try was gccemacs. The concept is simple, instead of just compiling elisp (the Emacs scripting language) to bytecode, you could just use gcc to compile every piece of elisp code into native machine code. That way, Emacs becomes blazingly fast, the only tradeoff being a bit longer installation process.

Despite being an experimental feature, I’ve been using gccemacs consistently for one month and never ran into a problem (just saw some compilation warnings when installing packages but nothing important). What’s more, thanks to the way Emacs is designed, my single init.el file worked seamlessly across five different Linux installations, from Ubuntu 16 to Arch, And even on a MacOS High Sierra virtual machine. This is one thing that I couldn’t do with NeoVim, as I had to download a lot of dependencies, which was a nightmare especially in Ubuntu 16 for being an ‘old’ distro. A lot of people fall for the ‘bloat’ meme when talking about Emacs, and although it is slower (not gccemacs in my experience) and consumes more memory (not that much compared to NeoVim with coc.nvim), the Emacs packages that I use do not need external tools such as Python or NodeJS. And I have the same functionality if not more.

But enough ranting, in this post I’d like to share the packages that I’ve been recollecting that replicate (and enhance) the workflow I had with vim. I hope this blog post can serve as a quick start for someone who is as lost as I first was.

Installation

You can install Emacs from your package manager of preference. If you want to try out gccemacs, you’ll have to follow the instructions here. You’ll most likely need to compile Emacs from source, but it’s not very complicated.

Package manager

Next comes the package manager. Emacs lets you manage all your packages by hand, but if you are a sane person, you’d like some sort of package management. straight.el has lots of interesting features that contribute to reproducibility and hackability, but one feature that doesn’t get mentioned right away is that it automatically detects if you are using gccemacs, and if so, it autocompiles all your packages in a non blocking way. This is very sweet, as you can use your packages while they are being compiled.

Another feature I liked was the ability to do a shallow clone of the packages, thus saving a lot of space. But at the time of writing this feature is still experimental and I experienced some problems with it, so I did not enable it.

Evil mode

The next step is Evil mode, as leaving vim does not imply leaving the ‘vim language’. Evil mode is an emulation layer of vim, that makes emacs behave like vim in almost every part of the editor. You’ll need to learn some basic Emacs keybindings tough, like ‘C-g’ for exiting. In my config I have the following Evil packages:

Config for comfy programming

Since most of what I do is programming, writing LaTeX for university assignments and notes, my current config revolves around just that. I don’t want Emacs to creep up and become my Operating System (yet). So this are the packages I’m using at the moment:

Productivity

I also use other packages, both for extra functionality and for GUI goodness. For enhancing your workflow I recommend the following:

GUI enhancements

The GUI part is the most subjective, and that’s why I left it last. The packages I use are:

Conclusion

I am very surprised by how much Emacs can be made to behave like Vim, there is virtually no difference.

If you don’t like slow start-up times, you can just make your computer run emacs --daemon when logging in. This creates an Emacs server, to which you then can connect running emacsclient -c. That way you can ‘open’ Emacs almost instantaneously.

There is room for lots of improvements, as I only have been using Emacs for less than a month. But with this configuration of less than 300 lines I am pretty comfortable.

Emacs