My 2.5 Year Journey with Vim and Why I Switched Back to Sublime Text

David Han
In the weeds
Published in
10 min readJun 1, 2017

I always enjoyed learning new keyboard shortcuts and finding ways to optimize my workflow, which naturally led me to use vim. Vim was very appealing to me because it promised a faster workflow by decreasing the number of keystrokes and allowing me to never have to switch from my keyboard to the mouse as I write software. Watching other developers on my team use vim, I was fascinated by how quickly they were able to find and edit text and, despite the learning curve, I decided to jump in and start learning vim. That was 2.5 years ago, but I recently switched back to the first text editor I was introduced to — Sublime Text. I did enjoy using vim and still do in some ways, but as we should always ask of our projects — “what is the best tool for the job?” — we should also ask this of our text editors, and I don’t think vim is the best tool for the job.

I wouldn’t say that this is true for all developers and I’m not saying that vim is a bad tool, but I am saying that it isn’t the best tool for the type of work I am responsible for. At Greenhouse, product engineers primarily work in Ruby (on Rails) and Javascript. Here are some of the most common text editor commands that I need to perform and which of the two editors I believe does a better job. More detailed reasons are provided below.

Fuzzy find file search

Both vim’s cntrlp and sublime text’s command p function the same way for the most part and there is no clear winner.

Find and replace within a single file

This is probably the most common use case out of all the text editing I do. As a Rails/Javascript developer, I can’t think of anything I do more often than renaming variables and methods. Naming is one of the hardest problems in software development, so renaming is something that we are having to do constantly.

Sublime Textcntrl+option+g will select all occurrences, and then you can start typing what you want to change the text to.

Vim:%s/firstname/first_name/g will find all occurrences of firstname within this file and replace it to first_name.

The number of keystrokes for ST is 15: 3 (ctrl+option+g) plus 11 (the number of characters in the new word first_name) plus 1 (esc) to remove highlights.

The number of keystrokes for vim is 25: 4 (:%s/) plus 10 (the number of letters for the old word firstname) plus 11 (the number of letters for the new word 11 first_name).

ST is the clear winner for this category.

Global find and replace within a project

This is another common use case where you need to rename a database model in rails or any name across a project. Let’s say you you started out with the model name of GreenhouseUser and you decide to rename it to just User; you would have to do a global find and replace.

Vim — if you look at the first search result for “vim global find and replace in a project”, this is the link that it takes you to. The first example in the link says to do this:

:args *.txt
:argdo %s/Vimcasts\.\zscom/org/ge
:argdo update

The other examples on the same page seem to only get more complex.

I’ve actually never tried this and I don’t want to. It shouldn’t be complicated to do something that is so common.

The second result is a link to a stackoverflow post that mentions Greplace— a pretty good option for global find and replace, although it takes a fair amount of reading and understanding to know how to use it (the steps are not the most intuitive so I don’t actually remember how to do it).

ST cmd+option+f opens up a dialog. Type in the old word in Find, type in the new word in Replace, and you’re done (path/to/project should already be there automatically based on the project you’re working on).

ST is the clear winner since it’s very intuitive and you don’t need a plugin to accomplish this.

Jump to method definition

This is one of the most important and useful features in any text editor.

Vim — it takes several steps to get this working. If you don’t already have it, you probably should install exuberant ctags. Then, you need to create a ctags file where you can add rules for how ctags will find the method definitions. In order for ctags to index your files to be searchable, you need to run a command while in your project directory:

$ ctags -R

Finally, you probably want to add some type of plugin that allows you to index your files every time you switch git branches — otherwise, you have to remember to run ctags -R every time.

For some reason, I had a very difficult time getting ctags to work with my javascript files. I have spent hours configuring my ctags to work for javascript, but it never really worked as expected until I copied the ctag rules of a co-worker and it finally worked. Do a google search for “vim ctags for javascript” and you’ll get multiple results for many different ways to implement ctags for javascript with no clear optimal choice. It also takes a nontrivial amount of time to even get it working if you’re unfamiliar with ctags and vim.

Once all of the above is complete, you can place your cursor in a method and press ctrl+] to jump to the method definition.

ST — in your sublime settings file, add this line:

"index_files": true

and you’re done. Place your cursor on a method and press option+cmd+down to jump to the method definition. This works in javascript as well without extra setup.

Vim (ctrl+]) always immediately jumps to the first reference it thinks is correct whether or not there are multiple occurrences. Sublime text, on the other hand, knows to jump to a definition only if there is one occurrence in the project and provides a dropdown to choose from when there is more than one occurrence. This is a smarter default that any user would want.

ST is a clear winner in this category since it only takes one line of setup to start using this feature and there is better default behavior.

Multiple Cursors

Vim doesn’t have this feature out of the box, but there is a popular plugin called vim multiple cursors which tries to mimic sublime text’s multiple cursor behavior.

The first example in the repo shows this gif:

Vim — This feature works as expected in most cases, but I found that it clashes with other vim plugins related to snippets and occasionally causes some weird auto expanded text bugs.

ST — This feature is called “Quick add next” in ST. I’ve never had any issues with it — it always works as expected.

Here is another gif from the repo that shows vim multiple cursors in action:

The caption right below this gif explains how to make this change:

Vim command sequence: 2Gvip<C-n>i"<Right><Right><Right>",<Esc>vipJ$r]Idays = [

Vim — Even after using vim for 2.5 years, it takes me awhile to grok what this sequence is doing. This may be easy to understand for a seasoned vim user, but for any beginner, this approach is unintuitive and unlikely to be adopted. Even if you do figure it out, this type of change is usually infrequent, and because the approach is unintuitive, you’d have to relearn it each time.

ST — Any sublime text user who has used multiple cursors before knows that this is a trivial change to make. The sequence of commands is intuitive and you can easily perform this change whenever it is necessary. For more information on how to do this, see the multiple selections section on the ST homepage.

Other reasons why I am leaving vim

Sublime text editing has a more intuitive and tangible visual element to it

Vim always felt a bit abstract to me. Of course I can string commands that tell vim to take these 3 lines and move them 6 lines above (the command sequence to do this in vim is shift+v2j:m-6), but the commands I need to formulate feel distant from what I want to achieve. I don’t want to sit there and run calculations on line numbers or characters for commands I want to do — I just want to do them. It’s as if you were asked to play chess by inputting commands that tell a chess piece how many spaces forward and across to move on the board rather than simply using your hand to move it.

The differences can be seen in the gifs below:

select 3 lines and move them 6 lines above in vim
select 3 lines and move them up and down in sublime text.

Pairing

It is impossible to pair effectively if the person you’re pairing with is unfamiliar with vim. This is not the case for most other text editors.

Vim is a low level tool

My text editor is a means to an end. I want my text editor to do just that — edit text. Time spent figuring out and editing my text editor is time I could have spent shipping software. There’s a reason why most companies don’t only use jQuery or Ruby to build complex software and instead, use more opinionated libraries like Ruby on Rails and React. Without more opinionated tools, we would have to make many more small decisions in order to write any software feature rather than having conventions for most common use cases which enable us to deliver software more efficiently. The same principle applies to text editing. Vim is so low level of a tool that it not only requires learning all the basic commands, but spending many hours configuring your text editor in order to have some smart default ways to handle common use cases.

I’m aware that the flexibility vim provides is one of the main reasons why people use vim but I don’t think the time commitment this requires is worth it, especially for more novice programmers.

I’ve extensively used both of the main vim distributions, janus and spf13, which try to configure vim to be more full featured and to have smarter defaults. Even with these distributions, you still need to spend a significant amount of time to learn the plugins that it contains and further configuring it to your needs. Often times it makes your local configurations much more complex to deal with especially when trying to override existing configurations.

Turnaround time for learning an editor feature

And finally, I can’t justify using vim because any editor feature I want to learn has a much larger turnaround time than most other text editors. I’ve given examples in this post that the google searches related to vim led to rabbit holes with no clear solution to easily get something done.

I get paid to build software and not edit my vim config. Most vim users would argue that once you get past the learning curve, it will make you much more efficient in the long run. If we’re just talking about keystrokes, I’ve also demonstrated in this post that for some of the most common use cases, sublime text uses less keystrokes than vim and perform these changes more seamlessly than vim.

Sublime vintage mode

With all this said, I still have great respect for vim and I’m glad to have learned it. It has ultimately made me a better editor of text. Now that I have used vim, there are certain basic commands that I cannot live without. A few examples are:

ciw — change inside word

ci" — change inside punctuation mark of choice. Can also be ci[ , ci( , etc.

. — repeat command

and many others.

I have been using Sublime Text with vintage mode on, which allows these basic vim commands to be available. So far, I haven’t had any problems that weren’t solvable by adding a custom key binding while using vintage mode. If vintage mode happens to cause an issue, it can easily be turned off by doing-cmd+option+p (opens command pallete), selecting Package Control: Disable Package , then select Vintage.

Closing thoughts

Sublime Text is still not the perfect tool and doesn’t have good answers for some powerful plugins that vim provides like rails vim and has packages that aren’t as full featured as vim rspec and vim fugitive. Atom seems very promising. Based on my quick research, it seems to have plugins that are comparable to vim fugitive, vim rspec, and rails vim, so I’ll be trying it out soon. I’m searching for a text editor that can provide the best of both worlds — basic vim commands + a more intuitive editor. Once I pick an editor, I’ll write a follow up post on “How to configure your sublime text/atom editor as a former vim user”.

These views do not reflect the views of the engineering team at Greenhouse Software and are my own. We have engineers using many different text editors including vim users who are much more proficient at using vim than I am.

--

--