Switching from Vim to Atom
(A Haskeller's Perspective)

Posted on March 7, 2015 (last updated Aug 23, 2016)

I have been a Vim user for many many years, but have long wanted to switch to an editor that was more easily hackable. I tried Emacs and Sublime, but both had various hurdles that were just too annoying for me and both times I switched back to vim very quickly. However, I started using Atom a while back, and I have to say, I liked it from the start. I very quickly felt almost as productive as I was in vim, and in some ways I already much prefer Atom. (And since it’s JavaScript, we can write plugins in Haskell!)

Below are some tips that helped me transition from Vim to Atom.

Multiple Cursors

Multiple cursors, inspired by Sublime I think, are absolutely awesome. Many things that I would previously use a regexp for I now do much more quickly with multiple cursors. For example, here’s an example making a curried function uncurried:

Note that multiple cursors don’t have to stay in the same column, even if they start out that way. Each cursor responds to key commands independently. This is tremendously useful; for example, consider this example of removing parentheses:

Nor do they have to be on consecutive lines as in this example of removing some linebreaks:

On Mac, Shift-Control-Down (or Up) extends the cursor to the line below (or above). (You will want to disable the Mission Control and Application Windows shortcuts.)

Indentation

(No) Auto-indentation

I hate editors that try to be smart about indentation with a passion. I’ll decide my own indentation, thank you very much. The only thing I want an editor to do by default is to copy the indentation from the previous line (vim’s :set ai). Thankfully, Atom does this out of the box.

(No) Tabs

One thing that is a bit annoying with Atom’s default settings is the treatment of tabs. By default, it’s using soft tabs, and that’s good, but it tries to be smart about recognizing multiple spaces as soft tabs and that’s not so good. The problem is that in Haskell code (in mine at least?) the indentation is not always an even number of “tabs”; instead, the indentation is dictated by the code. Here’s an example of where this can go wrong; all I do in this screencap is press space and then backspace:

This gets even more annoying when using multiple cursors, because now the behaviour on each line depends on whether Atom happens to recognize a soft tab or not:

Thankfully, this problem is easily solved by setting the length of a soft tab to 1.

Indentation help

Some help with indentation is useful though (when requested!). Multiple cursors can help here too. For example, we can use ⌘-D to add the next occurrence of the word or symbol under the cursor, and then use the atom-alignment package to justify each of those cursors:

Alternatively, if we want to align different words, we can create multiple cursors by ⌘-clicking on the keywords we want to align:

Haskell Support

Writing Haskell code is what I do for a living, and there are few things that I find absolutely essential; thankfully, all of these are well supported in Atom:

Incidentally, the same ide-haskell package also supports ghc-mod, but I don’t personally use it so YMMV. Note that if you do want to use ghc-mod you’ll probably want to use a recent version of ghc-mod (5.4 or up); it should work with either cabal or stack.

Miscellaneous

Finally, a few miscellaneous Atom tips and some non-default packages.

I make use of the following additional packages: