Atom and vim-mode

Some years ago I started using VIM, mostly because it was nerdy and cool!

Back to serious, I had to manage some servers, edit nginx/ftp/ssh/mail config etc. all via ssh and at the same time I had to develop the apps that run on these servers, in short some dev-ops tasks.

VIM seemed a natural choice be it just to have a consistency in my development environment. So I started using it, initially the modal mode was strange but now I can’t think of using an editor without this mode.

Switch to Atom

I’ve always been curious about Atom and about one month ago I decided to try it seriously i.e. without going back to VIM for a while.

First of all, I installed vim-mode, thanks to this extension Atom acquires the VIM modal mode and all its basic commands.

Initially I used the VIM commands as usual to move through lines, replace etc. but the real power of vim-mode is the possibility to use these commands in combination with Atom multiple cursor.

The combination of these two features can be similar to a basic (very basic) implementation of VIM macros.

For example I have this Hash in ruby:

hash = {
  :foo => 'bar',
  :barbar => 'foo'
}

I want to change this old assignment mode :foo => 'bar' with the new foo: 'bar' but I want to do it for all hash attributes at once. In visual mode I can select => (note the space) and then press Cmd+D (multiple cursor), now I press d to remove then i to insert the ’:’ then I press [esc]^ to go at the first character of the line and press x, so I obtain this:

Short: select => then Cmd+D for each attribute I want to edit and finally di:[esc]^x[esc]

hash = {
  foo: 'bar',
  barbar: 'foo'
}

This is a minimal example just to show the possibilities of vim-mode and maybe convince you to try Atom. At the moment I have not abandoned VIM, sometimes I find myself thinking “I want my VIM back!” but the combination of vim-mode and multiple-cursor keeps me and it will keep me on Atom still for a while.

Leave a Reply

Please Login to comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.