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!

18 thoughts on “Why I switched from Vim to Emacs

  1. “Not everyone uses Emacs, so collaborating on projects can result in extra time
    conforming/converting to de facto industry standards.”

    I struggle with this as well. For my money, org-mode with latex/pdf export is the superior workflow for producing academic papers. But the chance of convincing my collaborators to drop their industry standard software is essentially 0. I find that pandoc is workable for converting org or tex documents to docx, although I frequently have to manually fix some of the formatting. Once I get into the more mature drafts of a paper, I generally stick with LibreOffice as well.

    It’s really a shame, but try convincing an MD who has 10 patients to see today that he/she should learn Emacs. Not gonna happen.

    • Good to know about latex/pdf export. I’ve tinkered with pandoc but haven’t been able to get it to work (not that I tried that hard yet). I’m certain I’ll try again in the future.

      I’m sure convincing an un-Emacs’d MD to learn Emacs would be next to impossible – ha… Although I have seen an MD (or two) floating around the interwebs that uses it. I would think an MD could really benefit from Emacs, but for a lot of people, no amount of convincing could get them to change. Especially when they would have to take a pretty large performance hit short term.

      I’m hoping to become a professor one day and take on grad students, making Emacs the research group’s standard. But could I find students who know/would be willing to learn Emacs? Not sure. I’ve never met anyone in my discipline who uses it. But hypothetically, this is where I’d begin the Emacs takeover.

      • Sort of as an aside regarding finding students who would be willing to learn Emacs…

        When I was in college I converted a friend of mine first over to using Linux, and then later over to using Emacs. Fast forward a few years and he’s interviewing for his first job out of school. Somehow Emacs comes up, and turns out the guy he’s interviewing with also uses Emacs. The two of them then proceed to have a discussion about how “no one just picks up Emacs. Some crazy Emacs enthusiast always needs to introduce it to you.” and then he gets the job. Turns out I was the “crazy Emacs enthusiast” he was thinking of.

  2. Nice article, emacs 255 support for xwidget https://www.reddit.com/r/emacs/comments/4srze9/watching_youtube_inside_emacs_25/ may address many of your issues, it’s still early, but huge potential there, also for web development too. I’d say the0 one perk I get from the default emacs bindings is that I have near universal keybindings for about a dozen or so core emacs strokes nearly everywhere in OSX – as it’s built into cocoa text widgets, so emacs, comand line, any text widget (to include the universal bar in browsers), supports them, even MS Outlook for OSX.

  3. Exporting from org-mode files directly to Word .doc format can be accomplished with the `unoconv’ tool, which should be available from your package manager. With that installed, you can customize `org-odt-convert-processes’ (adding e.g. ‘(“unoconv” “unoconv -f doc -o \”%o\” \”%i\””)), `org-odt-convert-process’ (to “unoconv”), and `org-odt-preferred-output-format’ to automatically produce .doc output alongside .odt when you export to that format.

    I *think* that’s all you need to do, and I don’t see any other references to it in my init files – but it’s been a year since I set that up, so I could be overlooking something. If you have trouble, feel free to ping me at the email address I used to post this comment, and we’ll sort it out. The Org manual’s salient section might also be of help: http://orgmode.org/manual/Extending-ODT-export.html#Extending-ODT-export

    Enjoy!

  4. Great article Matt!

    I have a few thoughts I’d like to share 🙂

    First, I find use-package is a great way to automatically install packages that are missing. In my case I first check to see if use-package is installed and if not, it automatically installs use-package and that in turn allows my configuration to be installed everywhere. All I need to do is download my emacs configuration on a new machine and open emacs and everything gets installed on it’s own 😀 I know your spacemacs solution works well for you; just thought you might find a vanilla emacs based approach to be interesting! (here’s a link to my emacs config: https://github.com/femtogram/emacs-config )

    Also, I absolutely agree with the emacs + vim being the best editor. I’ve been using emacs with evil mode from before spacemacs and I can’t imagine switching away.

    The new version of emacs can be compiled with a full built-in webkit. It doesn’t work perfectly yet, but it’s a great first step to being able to replace desktop environments with emacs 🙂

    I agree on the terminal emulator issues. I used to use multi-term, but now I just use the terminal emulator for whatever system I’m running.

    My efficiency went wayyy up when I found out about M-x clone-indirect-buffer and narrowing to regions. evil mode is better at being vim than vim because you can apply vim operations to just the narrowed region super easily.

    skeletor is a great tool for creating new projects.

    I find the tools that are indispensable for me are magit, evil, and projectile. My emacs config is very simple, but I guess that’s kind of the beauty of emacs; it doesn’t thrust any particular workflow upon you, but rather provides you the tools to build up a workflow that suites you best.

  5. Great Article.
    Pretty much like my own journey from Vim to (Spac)emacs.
    I switched around an year ago, and haven’t looked back. I occasionally open vim from terminal for a quick edit, but that is more out of habit/muscle memory than anything else. (So I created an alias and mapped vim to emacsclient)
    I do use “view” command a lot (for viewing logs) which is vi/m in read-only mode. Haven’t found emacs equivalent yet.

Leave a reply to haff112 Cancel reply