Why I switched from Vim to Emacs

EDIT:

As pointed out on reddit (both in r/emacs and r/vim), many of my criticisms of Vim are unfair. Everything I posted about was based purely on my personal experience with the two, but much of my critique was steeped in ignorance. That said, I won’t delete the post because I’ve learned a lot from the comments here and from the comments on r/Emacs and r/Vim. Maybe someone else who has similar issues could learn something too. I did, indeed, underestimate the Vim community! Summary: Take everything you read below with a grain of salt!

ORIGINAL POST:

When I first started using GNU/Linux, I tested both Vim and Emacs. Vim seemed
pretty intuitive and its keybindings were efficient; Emacs seemed impossible to
learn and its keybindings made little ergonomic sense. On a Stack Overflow
thread, I read about the pros/cons of both Vim and Emacs. One user noted that
you will never really be satisfied with your Emacs setup, you will constantly
be making modifications, and you will be useless if ever working from someone
else’s setup. Because of all these things, I chose Vim and became a Vim
proselyte.

Over time, however, I started finding inefficiencies in my workflow, and my
approach to using a terminal, editor, and IDEs was not sufficient. As I started
looking for solutions, I realized that Emacs held the key to all of them. I
hesitated on trying Emacs because I was well-entrenched in Vim and did not have
time to spend hours upon hours in a config file (even though deep down inside
all GNU/Linux users really do want this). Eventually, the bottleneck became
unbearable, and I stumbled upon this video which completely changed my
perspective on Emacs. The speaker in the video mentioned that Vim users could,
almost seamlessly, switch from Vim to Emacs with Spacemacs. I tried it and I was
hooked.

Below I go into more detail about the inefficiencies I found in my Vim-dependent
workflow and why I now use Emacs. For clarification, I do use the Spacemacs
distribution of Emacs, which has many features that Vanilla Emacs does not. My
explanations will focus on solutions specific to Spacemacs, but in theory what I
explain is distribution agnostic, and everything could apply to your individual
Emacs setup should you take the time to implement it.

Reasons why I switched

I didn’t have to stop using Vim

That’s right. I really didn’t switch to Emacs. I still use Vim keybindings for
everything inside Emacs. There are several ways to use Vim keybindings in
Emacs (Evil mode, Spacemacs, others?), and in my opinion, only a mad wo/man
would use Emacs keybindings long term. ‘Emacs pinky’ is no joke, though people
often seem to treat it as one. When I was considering making the switch to
Emacs, I was having considerable wrist and forearm pain (unrelated to Vim), so
an ergonomic editor was important to me. With Spacemacs, I could keep the
efficient keybindings of Vim while using something with more features.

Copying/yanking and paste from one window into another

Using Vim keybindings in Emacs through Spacemacs is such a beautiful experience.
Not only can you use Vim keybindings when writing code, you can use these
keybindings anywhere in Emacs including in shells. This is more convenient
than you might think. Say for example, you produced a typo (or multiple typos)
when issuing a shell command such as:

rn /home/user/folder1/folder1/folder3/folder4/folder5/some-file.txt

that was supposed to be written as:

rm /home/user/folder1/folder2/folder3/folder4/folder5/some-file.txt

Here, I needed to make two changes: ‘rn’ needed to be changed to ‘rm’ and the
second instance of ‘folder1’ needed to be changed to ‘folder2’. If you wanted to
modify this in a traditional terminal emulator, you would probably use the up
arrow to retrieve the last command, use the left arrow (or Ctrl-Home) to get to
the beginning of line to modify ‘rn’, then use the right arrow (perhaps in
combination with Ctrl) to modify the second instance of folder 1.

This is way easier with Emacs. Simply retrieve the previous command, get to the
beginning of the line with ‘0’, change ‘rn’, then navigate to second instance of
the number 1 using ‘/’ (or get there with ‘f1f1’). With both typos, ‘r’ can be
used to replace the errant character, instead of using a combination of arrows,
backspaces/deletes, etc. This is a Vim-approach to the terminal, all within
Emacs.

When I was using Vim, I used the terminal emulator ‘Terminator’, and would
frequently have 4-5 windows open with a combination of shells and files. Now
what if I wanted to copy a terminal command from one window and place it in a
code file? Or copy a command from one code file and place it into another code
file? The only way I really figured out how to do this was by selecting text
with the mouse (which I absofruitly abhor), using Ctrl-Shift-c to copy, and
Ctrl-Shift-v to paste in the new window. With spacemacs this is incredibly
simpler. Simply navigate to the window with your shell, use ‘yy’ to yank the
line you want, and navigate back to your code file. Switching windows in
Spacemacs is effortless (e.g., ‘SPC-1’ gets you to the first window), it can be
done without leaving the home row, and all of this copying/yanking and pasting
can be done {without the mouse}.

Trying to use Vim as an IDE

For a while, I was using Vim as my editor and debugging code in IDEs like
RStudio and PyCharm. Even though you can use Vim keybindings in both of these
IDEs, it was a pain switching back and forth between code, the console, the
variable explorer, etc. I also spend a great deal of time in the terminal, and I
use multiple languages in single projects, so having a language-specific IDE was
inconvenient. Because of this, I tried to turn Vim into an IDE with NerdTree and
Airline, but I never was able to get debugging to work inside Vim (some claim
to have accomplished this, but I never could get these solutions to work).

Some may argue against using Emacs as a full-fledged IDE, but it works fine for
me. For example, I can use Emacs as an R IDE with the Emacs Speaks Statistics
(ESS) package. I can edit, step line by line, and debug a code file; use
R-dired as a variable explorer; and enter console commands all within one
frame. It all feels like a more customizable experience that I have more control
over than a pre-packaged IDE. Emacs is more than an editor and even more than an
IDE; some view Emacs as basically a entire operating system (more on this in
the Tetris section).

Duplicating my setup

I work on many different machines and I like consistency. Unfortunately, I am
also very picky about my setup. Duplicating my Vim setup on a new machine
involved installing Vim, cloning my .vimrc from my Github dotfile repository,
creating a symbolic link from my cloned .vimrc to my ~/.vimrc, downloading the
several Vim themes I like to work with, installing Vundle, and then using Vundle
to install my Vim packages! Nightmare.

This is somewhat easier with Emacs (but still not without a little manual
labor); here, I first install Emacs (which you have to build from source on
Ubuntu to get an up-to-date version that will work with Spacemacs, which is why
I ultimately switched to Arch Linux. That’s right, I changed operating systems
because Emacs is easier to install on Arch. My next post ought to be ‘Why I
switched to Arch Linux’), clone my .spacemacs from my Github dotfile repository,
and create a symbolic link from this .spacemacs to ~/.spacemacs. Upon starting
Emacs, everything is installed for me, including themes. No installing a
package manager like Vundle manually. No downloading theme files individually
(this could be automated with Bash, I admit, but this would still be more work
than it is with Emacs). Installing packages in Emacs, in general, is very easy.

Philosophical approach

Some people hate the ‘philosophical baggage’ of the Free Software Foundation
(FSF) (of which Richard Stallman, the creator of Emacs, is Founder and
President), but I think the philosophy is very important. Then again, I am an
idealistic academic. Ironically, I see few academics committed to producing Free
Software (let alone using Emacs) though most of them are in publicly funded
positions. That said, Emacs introduced me to the FSF and its philosophical
goals, which align with my goals as an academic (the FSF probably wouldn’t like
that I’m using Arch Linux, but it’s certainly better than Ubuntu).

Community

The Vim/Emacs debate is often heated, but from what I can tell, Emacs users are
more passionate. There are a number of Emacs meetups around the country where
users share their setup and demonstrate useful tricks. Maybe this exists for
Vim, but the Emacs community is more visible. Vim is an incredibly useful tool.
But Emacs is a lifestyle. That was corny, I know.

Vim doesn’t have Tetris

Emacs has Tetris and Vim does not. The debate ought to end here.

But seriously, for someone who finds their workflow driven by the terminal, the
editor, and/or the IDE, this exposes an important aspect of Emacs – You can
live inside it. Here are some things I do in Emacs that I could not do in Vim:

  • Use the terminal (through eshell)
  • Check the weather (using forecast.io/dark sky API)
  • Use Google (using helm-google)
  • Check/send email
  • Write academic papers (using org-mode)
  • Keep track of my todo list and calendar (using org-mode)

Instead of using the terminal to launch Vim and open specific files, Emacs is
always open, and the items above are opened in buffers within Emacs. Some
people complain about the long load time of Emacs, but this is a non-factor for
me. My workflow is driven by Emacs; I rarely ever close it!

Org mode

Org mode is absofruitly incredible. Some people use Emacs just for org-mode,
including people who are not programmers. I first learned about some of the
features of org-mode as a tool for writing in this video, but these
videos would also be good starting points for org-mode.

Org mode is a tool for writing, creating outlines, keeping track of your
calendar, and much more. In fact, this post was created exclusively using
Spacemacs/org-mode and then exported to html.

Emacs is fun to learn

Any Vimscript that I learned was purely out of necessity, and most of the
Vimscript I used was simply copied from the internet and pasted into my .vimrc.
This was a pretty laborious process that I did not enjoy. Emacs is different.
Creating an Emacs configuration is fun. I find that I actually look forward to
learning Emacs-lisp, and doing so feels more meaningful than learning Vimscript.
I’m often shocked at what is available in Emacs, and I’m constantly finding new
ways to improve my workflow with it.

Conclusion

After being a Vim proselyte and then switching to Emacs, I’ve come to this
conclusion: Vim is not really an editor; it is set a keybindings. Sure, it can
be used as an editor (and I still use it as such occasionally), but Vim’s main
contribution is its keybindings, which are in fact, the best, and utterly
irreplaceable to me (I even use Vim keybindings in my web browsers).

Emacs is not really an editor to me either. The more I use Emacs, the more I
agree that it is virtually an operating system. It can be used as an editor, an
IDE, a terminal, an email client, a word processor, a calendar, a todo list, and
a life organizer. The Spacemacs motto sums up the Vim/Emacs debate perfectly:
“The best editor is neither Emacs nor Vim, it’s Emacs and Vim!” The two are
not mutually exclusive. In fact, they work wonderfully together.

Despite this, Spacemacs/Emacs is still not perfect, and I do still find some
barriers when using Emacs:

  • I haven’t found an Emacs terminal that I am completely sold on; that said, my
    ideal terminal might not exist yet. Eshell has 95% of what I need (and I use
    it the most often) but lacks support for shell input redirection, for example.
    When I need this, I open terminator instead. I always have issues getting Vim
    keybindings, among other things, to work in Ansiterm and Multiterm, and in
    general these emulators seem clunky.
  • I’m having problems with org-agenda that currently have me relying on Google
    Calendar as my main scheduler.
  • Email often has HTML content (which can’t be rendered in Emacs as far as I
    know), so I often use a web client instead.
  • Using interactive shells such as the Mongo Shell (MongoDB) and Psql
    (PostgreSQL) often don’t work as intended, and some of these projects are not
    maintained
  • Not everyone uses Emacs, so collaborating on projects can result in extra time
    conforming/converting to de facto industry standards. For example, I
    frequently share manuscripts with colleagues, and exporting from the de facto
    industry standard word processing program (which will go unnamed) is not ideal
    from Emacs. Because of this, I am currently exporting .org documents into
    LibreOffice (which works quite nicely) before sending to colleagues. After
    sending to colleagues however, I have to stick with either LibreOffice or the
    unmentionable de facto industry standard so that I can view comments, respond
    to comments and track changes. I’ve seen rumors on the internet that this can
    be resolved, but I have yet to figure it out.
  • Leaving Emacs to use a web browser is not the end of the world, but it would
    be nice to have a high quality web browser inside Emacs.

I have a feeling that much of this could be resolved if I either searched harder
for a solution, or created solutions myself. All in all, I am much happier with
my workflow not that I’m using Emacs. If you have recommendations on how I could
better use Emacs, please let me know!