Why I started learning Emacs in 2016

Why learn another editor in the first place?

The main role of a good editor is to not get into your way while working, and maybe even help a bit from time to time. If you are a programmer, chances are you are spending a large amount of time using one – and that’s why it’s so important to choose a good editor. Learning a new editor is always a big investment – significant time passes before you tame your chosen tool and adjust it to your needs.

I’m a long-time IntelliJ Idea user. And it’s great for Scala/Java development, probably the best in market. But then, in some ways it feels a bit heavy. Even for the tiniest experiment you have to create a “project”, with its own window, meta-data directory etc. You go through a short wizard, and then it has to be imported and indexed, and re-imported, re-indexed, …. Maybe it doesn’t sound like much – but it’s definitely not a “lightweight” experience.

And then there are all those cases where you just want to edit a file. Maybe it’s a simple HTML page, or a blog in markdown. Or maybe you want to quickly clone a repository from GitHub and just browse around without bothering with the whole importing process. That’s why you need another editor in addition to a full-blown IDE such as IntelliJ.

For many years I’ve used either Vim or Sublime, but I never really learned either well, I know only the basic shortcuts. But I decided that it’s about time to get to know at least one “regular” editor better. Choosing between Sublime, Atom, Vim and Emacs I decided to go with the last one. Why? Well, I’ve heard of all those legendary hackers using them, so even though I’m very far from being a legendary hacker, I wanted to join them at least on the editor lever. Secondly, Emacs seems to be gaining popularity among programming hipsters – again a good reason to try. Finally, it’s been around for so long, and it’s still being developed, also for new languages (see Ensime), that there must be something in it.

Results

As always, there are good and bad sides. After 3 months of the experiment, mostly spent configuring Emacs, trying different modes and learning elisp, I’m not yet sure which side wins. I’ll skip the rant on the completely different keybindings from everything else, as that’s just a characteristic of the tool. Considering Emacs’s age, you might think that all the other tools should use C-w for cut, not the other way round (I’m currently using IntelliJ for Scala and Emcas for everything else. I’m training my brain to be elastic enough to know when to use which keymap).

On the good side, it’s definitely great to have a homogenous editing experience whether I’m experimenting in PureScript, writing a blog in Markdown, browsing through a simple Scala project or making a quick CSS fix. Magit is great for git – if only there’s a .git in some parent directory, I can commit, branch, push using the same friendly (!) interface. Without creating any explicit projects, projectile has good heuristics on when a directory is part of a project and where’s the project root, allowing me to navigate to other files in the project (again, that’s usually demarcated by where the .git directory is) without any additional steps.

On both the mixed good&bad side, you have to configure everything yourself. Not surprisingly, it’s the same experience as with Linux. When I was young and smart I enjoyed spending long days recompiling everything from source using esoteric compiler settings I found on the Gentoo forums, and then spending some more days trying to get my sound card to work. But now I’m a happy MacOS user, happy as I don’t have to deal with those things. So with the Emacs experience of “configure everything” I feel a bit younger, but then I imagine I might want an editor which “just works” at some point.

On the definitely bad side, the quality of the different modes/packages (plugins) varies. They often offer inconsistent keybindings, which causes you to either re-define the keymaps in the configuration, or memorize different keybindings depending on which language you are currently in. For example, when editing Markdown the key combination I use for moving between words is assigned to changing the header size. Another thing is auto-indentation. In some languages it works great. In others, it often gets lost. I’m sure of course I could fix all of these flaws myself, by overwriting some elisp functions using the advice mechanism, for example. But then I don’t want to become a full-time Emacs configurator.

In the future …

Who knows, you might see me doing a live-coding presentation from Emacs one day. Or not ;).

Or maybe Jetbrains will develop an all-purpose editor basing on the excellent foundation they have in IntelliJ? Without the need to create projects, allowing me to just browse to a directory and edit files there. That would definitely be a very strong contestant in the editor wars.

  • Dave

    Consider Spacemacs

  • +1

  • ReneFroger

    I found Spacemacs too bloated and I didn’t got figured out how to prefer my configuration settings above that of spacemacs, after one hour studying the documentation.

  • I did, and maybe it’s a great choice, however when initially doing the research it wasn’t quite clear for me how emacs compares to spacemacs – is it an add-on, a preconfigured set of mods, or a completely different editor? Do I get the same configurability as with emcas, or am I constrained by what spacemacs implements?

    E.g. the keybindings seems to be different, so that make it look like a separate ecosystem. I didn’t want to get too niche right upfront.

    But then maybe, I should just try :)

  • Spacemacs takes the form of a premade .emacs.d directory. You just git clone the config and launch emacs.

  • Austin Smith

    Plus all the bloat adds a very noticeable input-delay. But I’m on Windows where all GNU programs have worse performance in general.

  • Brent_Taylor

    That input delay is killer in spacemacs (on windows). I have to say however, I think it says rather a lot about spacemacs that I switched to doing all of my dev work on linux in order to continue using it. It’s just _that_ good.

    I switched to using Emacs with spacemacs about three months ago. Previously I’d used VIM as my primary editor for approximately a decade. I’ve no reason to switch back.

  • ReneFroger
  • Emacs is also my favorite editor. I’ve been on and off and back on it, several times already, there are times when I hate it. But I keep coming back, because there’s literary no replacement for Emacs.

    There are things that only Emacs does right. For example only Emacs seems to have implemented line wrapping correctly. If you ever see a Scala source file with doc comments neatly wrapped or a markdown document with lines neatly wrapped, then the author is probably using Emacs ;-)

    Another thing is the Undo operation. In Emacs Undo is an operation that in itself can be undone. Basically the Undo/Redo operations in Emacs do not destroy your previous state. I haven’t seen this behavior in any of the mainstream editors or IDEs I’ve tried. I remember the days of Textmate one and couldn’t understand why people like it when its Undo operation was char-by-char, totally useless and so basically retarded.

    Yet another thing is that in Emacs everything is driven by functions operating on text and for this reason it has great macros. Whenever I have a repetitive editing job to do, I fire up Emacs because I haven’t found any other editor with such great macros. Vim comes probably close though, but the modern ones (e.g. Sublime, Atom, VS Code) are unusable.

    It also has great plugins. If you’re into Lisp, then you can’t find a better environment. Plugins like Paredit work best in Emacs. I also use Projectile. And be sure to not miss Yasnippets. And Org-Mode. I think about half of Emacs users cannot leave Emacs because of Org-Mode.

    On shortcuts – they get a lot easier if you remap your Caps-Lock to be another Ctrl. This is a great idea not just for Emacs, but for Vim and other editors as well.

    And Emacs’s shortcuts are not that uncommon in the Unix world. For example your terminal / Bash also uses Emacs shortcuts. And after some practice you’ll feel very productive with them. For instance Emacs users (and probably Vim users as well) scroll much less than other people, because we jump around by means of text searches.

    All in all, I keep coming back to Emacs because it is a very smart editor. It does have flaws though and I keep waiting for a better editor to happen, but it hasn’t happened yet. And in 20 years from now I know that Emacs will still be around and active, but I’m not so sure about all the others.

  • Austin Smith

    Yep. Magit is basically unusable on Windows. Depending on how many files/changes it needs to process, it can take up to 10 seconds or longer just to view the status window, and that’s on my pretty fast computer.

  • I’ll try the Caps-Lock idea, thanks :)

  • Channing Walton

    Spacemacs is just emacs with a reasonable set of defaults, plus a nice way of organising and configuring packages.
    By default it uses evil mode to give you a vi-like editor experience, but you can turn it off. And the key bindings are designed for discovery.
    After trying to do things myself for a while I’ve found Spacemacs makes things much easier for me.

  • Channing Walton

    Since you’re a Mac user you might like to use the railwaycats build of emacs – https://github.com/railwaycat/homebrew-emacsmacport

  • Thanks! So far I’m using https://emacsformacosx.com, not sure how these relate (they probably don’t :) )

  • Ah yes, that’s another things that scared me off a bit. Mixed vim+emacs … I’m not sure if that’s a good idea for a start :)

  • Channing Walton

    The thing I like about it is that I can edit with vi and use the same keybindings.

  • Channing Walton

    No, the railway cats version adds a few Mac specific things to make the experience better – not a lot but it’s nicer.

  • torwag

    and now you are ready to enter level 2 and learn about org-mode in emacs and soon you will use emacs not only for coding and writing texts, but for organizing, brainstorming, note taking, etc. and sure enough you will spend even more time in configuration and optimization of your workflow. Try and be prepared for yet another season of emacs fun.

  • Brian

    The nice thing about emacs is it works in both terminal and GUI mode but it is more complex than vim however I’ve been learning it after 20 years on vim because it offfers and entire remote environment on the console.

  • Alan Third

    I like the fact that macOS supports some of the same shortcut keys as emacs, so I can use C-a, C-e, C-d, etc. in Chrome text boxes. I don’t think Chrome even supports that on Linux. :)

  • Riccardo Merolla

    I’m doing the same…I’m waiting to see you doing a live-coding presentation from Emacs :-D

  • I think it is a good start. I came from Vim as well. I don’t use spacemacs though — I customize evil mode directly. IMO, Vim kebinding is much nicer in general (that’s one of the reasons I code Vim initially), but emacs is much more customizable and the APIs are more elegant. I set the insert mode of evil to use Emacs kebindings, so I get the best of both. With evil, you can do even more customization, like define short Vim-like command when all common key shortcuts are already too long. You will still experience Emacs, cause you’ll write elisp ;)

  • Alex Koval

    Emacs allows unlimited configuration and improvements. It does not look very modern comparing to Atom, Sublime or InelliJ*, but.. The fact is that none of the modern tools can do everything the way I want – I always find some places, which are not functioning well or just missing parts of functionality – while in Emacs there are always several approaches to do it. Of course, may be not everyone needs this freedom – most of people would be satisfied with some average defaults. I am not, I like to always improve my workflow. As result, I learn things from other editors and port them to emacs one by one, using snippets or emacs packages. Emacs configuration for someone doing sci research vs python developer vs someone who does Java – all those will be very different. I am python developer, project manager and DevOps, and my config is here: https://bitbucket.org/avkoval/.emacs.d

  • Stwerp

    “the completely different keybindings from everything else”

    You’re on MacOS, those same keybindings persist. C-a, C-e, C-k, C-f/p/n/b, C-y C-l all work in standard mac text editing locations. It’s an awesome feature of mac to have the bash/emacs keybindings right there OS-wide.

  • Mike

    Have you opened a feature request to jetbrains for your “allowing me to just browse to a directory and edit files there” feature? https://youtrack.jetbrains.com

  • True :) But not all of them … copy-paste being the most common I suppose

  • I didn’t, but wouldn’t that change the whole approach of IntelliJ and be in fact a feature request for a completely new product? :)

  • Mike
  • It would definitely make sense from the user’s point of view … but maybe it doesn’t from a business PoV. Or maybe there’s something about the architecture of IntelliJ, WebStorm etc. which would make this difficult/slow/etc

  • Roman Melnyk

    Adam, have you ever tried to open and edit https://github.com/softwaremill/bootzooka in emacs? For some reason, List all references to the symbol or even Jump to the definition of the symbol does not always work. Try anything from/to bootzooka/backend/src/main/scala/com/softwaremill/bootzooka/common/api/RoutesSupport.scala

  • I didn’t, still using IntelliJ for Scala and Emacs for everything else ;) Though I would be surprised if there was anything specific in bootzooka wrt to Emacs integration …