How I made Atom into Vim
If you are a vim user like me, you probably had to use other other text editors at some point, and you didn’t enjoy it. The first logical step is looking for the Vim plugin for your text editor, but in reality they are pretty much all bad. No visual block mode, no jumps (ctrl-O), not even ex-mode in some of them.
But I like to try new text editors all the time. When I saw atom for the first time I saw it had promise, being incredibly customisable and built on top of web technologies. I imagined that someone must have made a good vim plugin for it, and if they didn’t do a good job I could at least tweak it.
So I tried Atom for the first time and I was pleasantly surprised. It has ex-mode(Althought very incomplete and as a different plugin). It supported most things I usually do on vim, even some complex commands. However it had a major flaw to me. Vim-mode(the atom package, now vim-mode-plus try the new version) didn’t support jumps(Ctrl-O, Ctrl-I) something I use frequently while coding. So I decided to follow the Atom’s way and hack it.
TIP:Installing a package in atom is incredibly simple, you can do it through command line
apm install ‘package name’
(no ‘’) or on Atom itself you can look for packages by using Ctrl+Shift+P and looking or ‘Install Packages’
I am happy to say it wasn’t terribly hard. First I looked for a plugin or as atom calls it a package, that would do the same as jumps in Vim. I found cursor-history, and it seemed to work perfectly, but I needed my vim keybindings.
So after a bit more research on how atom packages worked, I learned they are based on a CSON file.(Coffe script object notation, very similar to JSON). And inside the config folder(~/.atom on linux) every package had their own folder.With a little tinkering I figured out that adding the following code, allowed me to add keybindings for the jumps on the global keymap.cson (‘~/.atom/keymap.cson’)
After seeing how easy it was to add my own keybindings for package function I decided to keep going.
TIP: Atom will reload your keybindings as soon as you save the file, no need to restart it before you try it.
imap jj <ESC>
Another one of my top priorities was mapping “JJ” as my escape key. Thankfully vim-mode does a great job with hotkeys. However this time we must add the hotkey directly into the vim-mode keybindings (~/.atom/packages/vim-mode/keymaps/vim-mode.cson), as it should only trigger on normal mode.
As you can see, instead of completely writing a new block of hotkeys(As I did for atom-workspace) I just added my ‘J J’ Keybinding inside the existing insert mode block. Adding another keybinding into vim-mode is always useful because it allows you to have flexibility on what modes that keybinding is triggered on. However it doesn’t work very well when overwriting a global keymap such as Ctrl-O for opening a file.
Spell check z=
If you use vim for spell checking, while writing Markdown or Tex files, you are probably familiar with ‘z=’. As I do a lot of university work on my text editor this feature is essential. Atom comes with a pre-installed spell-check package. So I decided to add another keybinding to my global keymap.cson.
Pre-installed packages don’t come with their individual folders and configurations. They use the global configs for atom. Therefore if you go into your keymap.cson on the root folder you can add ’z =’: ‘spell-check:correct-misspelling’
.
This could and probably should be added as an normal mode key binding. However is also a lot easier for you to keep track of your modifications if you keep all your keybindings in this global file, instead of meshed on the hundreds of lines of code, of vim-mode.
After getting familiar with the Atom way of hacking it is quite impressive what you can do in a couple minutes by merging packages together.
TIP: Ctrl + . will bring out the key-binding resolver, this is great to figure out what is happening behind the scenes, and figure out a function’s name.
What I think of Atom
After those small tweaks Atom was finally usable for me, but of course there is a couple of things to keep in mind. As I mentioned ex mode on atom is quite lacking, but this isn’t a problem thanks to Atom’s ctrl+shift+p. Atom provides a fuzzy command finder which allows you to call basically any function almost like an improved ex-mode. Just start typing anything and you probably find what you want. Atom is also incredible slow if you compare it to vim. However most of the times that isn’t a problem, and when it is vim is always there for you.
Another thing that keeps me from most text editors, is my vim plugins. Even a good vim-wrapper won’t have all the plugins that I am used to. However as you can see from my Atom package recommendations below, most are default in Atom or have a similar plugin, easily installed through APM(Atom package manager).
Why Atom?
Now many of you are asking why Atom? I’ve been using vim for years and it has been working just fine. I agree, there is no special thing that Atom can do that will make you stop using vim at this moment. However the greatest feature of Atom, it’s the fact that it is so hackable and so easy to build upon. Yes some of will have hundreds of lines in your .vimrc and maybe even your own plugins like me. However the point is when a new language appears such as coffee-script or typescript. Atom will support it almost instantly. This is simply because anyone with a little programming skill can quickly write a syntax highlighter and a linter for Atom. At the end of the day it boils down to the fact that coffee-script(Atom’s package language) is easier to develop in comparison to vimL.
If you don’t believe me, take a look of what Facebook is doing. You probably have heard of React or maybe Hack(Facebook’s version of PHP). Due to React’s new ‘modern’ syntax Facebook decided to make their own IDE for it, but instead of spending thousands of hours in developing a brand new IDE. They made Nuclide, an incredibly complex and powerful package for Atom. Nuclide completely transforms Atom in Facebook’s own IDE. The great advantage for Facebook is that they can reuse most of Atom’s code, and save hundreds of hours in development. Meanwhile for developers like us we can use Nuclide with all our Atom settings(including vim bindings) in this new IDE.
For me there are two main things that make me come back to Atom. One is as I mentioned it’s great to develop in new technologies as it will be one of the first text-editors to support new technologies. As well as the fact that I don’t have to commit. I don’t have to learn Atom to use it as I had to do with Vim. I can teach Atom to work the way I like, and today transitioning between Atom and Vim for me is quite simple and takes little to no adjustment. As a last bonus Atom is properly cross platform.