Using Vim in the Modern Web World

In the modern development world, especially web development, it is becoming more common for developers to use a handy text editor and terminal in place of a full IDE. The first names that come to mind are Sublime Text, Atom, TextMate, and Visual Studio Code.

Vundle

A friend of mine told me that when he made the switch to Vim, it was with the idea that he was going to hold it accountable for all of the things he had gotten used to from Sublime. So I used that same approach.

Step 1: find a substitute for Sublime’s Package Control — Vundle

Step 2: find a good list of plugins — vimawesome

Step 3: go crazy with my .vimrc to bring in keyboard shortcuts that I’m used to.

.vimrc

The .vimrc file functions very similarly to the .bashrc or .bash_profile files. Its purpose is to tell Vim what customizations to use every time it launches. Additionally, Vundle plugins go in .vimrc. Here is mine: https://github.com/jwkicklighter/dotfiles/blob/master/vim/vimrc

Are Plugins Enough?

I know I’m going to make some people angry here, but no they are not. The plugin support is incredible, and I was able to get vim to perform things that I really didn’t think were possible. Not only that, but vim’s age and availability means that there are a lot of plugins around. But sometimes, that just isn’t enough.

Don’t get me wrong, MacVim has become my default text editor and I love it for most use cases. But some projects just really need an IDE. It isn’t vim’s fault, there is just no way that I would try to work on an Android app of any size with a text editor and terminal. That goes for any Java app, for that matter.

Why That Doesn’t Matter

The side effect of using vim for just a few short weeks is that I immediately came to expect the movement keys and various vim commands to work anywhere that I could input text. Working on an Android app in Android Studio or a Rails project in RubyMine, I can’t count the number of times I have hit “<ESC>:w” expecting the project to save. I frequently add long strings of j’s & k’s to my source code before I realize that my cursor isn’t moving anywhere. Vim got me used to a new way of doing things, and that’s awesome.

You can’t learn to use vim by staring at a chart of the keyboard layout.

Using vim makes me continually think about what I am doing. Sure I’m [generally] thinking about the code that I am writing, but there is something different about it when every set of keystrokes could possibly be more efficient with the right thought ahead of time. You can’t learn to use vim by staring at a chart of the keyboard layout. It takes practice. Now I’m not saying go crazy and analyze your every move to the point that your productivity halts; I use way more up/down/left/right than I could if I thought about every movement a little longer. But sometimes I decide to think through a search/replace or cut/paste before taking action, and I learn something really cool as a result.

See, the thing about vim is that it was built because of vi. And the thing about vi is that it’s old. I mean old. We’re talking 40 years here. That means the keys and commands are very well known to the developer community. That also means that almost every text editor and IDE out there has a way to emulate some form of vim’s keyboard boobytraps. A lot of them even have official plugins or built-in vim modes (Sublime Text, Atom, the whole suite of IntelliJ-based IDEs). I immediately downloaded the IdeaVim plugin for RubyMine, Android Studio, & IntelliJ IDEA and through my custom shortcuts into a .ideavimrc file.

So I encourage you to take a little time to learn vim and make it work for you. It isn’t easy, and you will get frustrated. People who have been using the editor for years still do double-takes and redo some of their typing to figure out how they could have used vim to edit something more quickly. But you might find that you actually love the result, like I did.

Like what you read? Give Jordan Kicklighter a round of applause.

From a quick cheer to a standing ovation, clap to show how much you enjoyed this story.