Antoine Lehurt

From Sublime Text to Vim

Sublime Text has been the first text editor I really enjoyed to use. Fast, simple to customize and lots of great plugins.

Progressively, my habits have changed. At first, for instance, I used to rely on the UI to find a file and double click to open it. Then I discovered the fuzzy finder (cmd + t) which helped me to switch quickly between files. A simple thing that improved my workflow a lot.

Throughout my use of Sublime Text, I wanted to have a more comfortable experience, especially during code editing (selection, navigation, etc.), by reducing the back and forth between the keyboard and the mouse.

I first looked into Sublime Text settings to try out some options:

And of course there are several plugins that helped me. I particularly enjoy Easy Motion “that allows you to move the cursor to any character in your current view”. It lets you navigate quickly inside your code, and for me, it is as important as the fuzzy finder. In fact, when I started to use this plugin, I wanted to do everything in that way. Being able to delete a text, starting from the position of the cursor to a defined character somewhere on my screen, would have been awesome.

Unfortunately I did not find a plugin to fulfil my need.

The discovery of Vim

After some research, I decided to give Vim a try. In order to facilitate the transition, I started to use Vim as I did with Sublime Text, following Yehuda Katz advice. I installed MacVim and searched an equivalent for each of my favourite plugins:

In parallel, I read the book Practical Vim, which allowed me to familiarize myself with the Vim commands and discover the range of possibilities they offer.

Everyday, I set out a goal to focus on a specific command. It allows me not to overload my memory with a lot of new commands and not spend too much time looking for the right way to do it. With the intention of remaining productive in my work.

Step by step I reduced my use of the mouse, disabled the arrow keys and finally started to use more and more word wise motions to navigate inside my code.

Magic motions

In Vim, when you execute an operator command (copy, change, delete, select, etc.), you use motions to tell where you want the cursor to move.

Motions are pretty simple to remember. For example i mean “inner”, so if you want to delete the text inside the braces: di}. This is very powerful and can be applied in different context, such as search keys (f and t). There is a really interesting article about text objects by Jared Carroll. Efficient editing in Vim is a matter of learning how to speak proper Vim.

The use of motions is the first thing I truly enjoyed with Vim and that was exactly what I was looking for. That made me switch definitively to Vim.

6 months later

I’ve mostly found everything I used to use in Sublime Text. However, I had to spend some hours to configure Vim. It is annoying to start with an empty shell but I’ve found lots of .vimrc on GitHub to used as an example.

It might be sometimes difficult to achieve tasks that were relatively simple in Sublime Text. I had to learn new tools like The Silver Searcher, to be able to search and replace strings in my project.

It is nevertheless really pleasant to edit my code in Vim. I still have a lot to learn but this is also something I like, I am always thrilled to discover new things and I never get bored.

Some links that might be useful: