unit and acceptance testing, automation, productivity

XVim, harnessing the king of text editor's power in Xcode

This post is going to be controversial. In this post I am going to try to convince you to use XVim, an Xcode plugin to use Vim keybindings and other feature in Xcode.

This post is about productivity. Not the life hacking kind of productivity, or the one that To-Do list apps try to sell you. This post is about real productivity, the one you get by mastering your tools in such a way that tasks that would require series of clicks in dropdown menus can be achieved with a simple keyboard shortcut.

So, in full productivity post spirit, let me give you 4 reasons why you should use XVim.

Vim motion

How many time in a day do you move your hand from the keyboard to the mouse or trackpad, or to the arrows keys, to move the cursor around? Probably a lot. Using XVim you can move the cursor around using the h, j, k, and l keys, respectively left, up, down and right. Notice how those keys are in the home row of a keyboard with a QWERTY layout. That means minimum travel time for you fingers.

Vim fingers

And if that doesn't impress you, let's look at more motion commands.

  • b and e will move you to the beginning and end of the word your cursor is on.
  • ^ and $ will move you to the beginning and end of the current line.
  • H, M and L will move your cursor to the top, middle, and bottom of the window.

All these commands can be used with a number at the start, for example 3j will move you 3 rows down, 4h 4 characters left, and so on.

All these keys work when you are in normal mode, once you are in the desired position you can start actually typing characters by switching to insert mode.

There are different ways to switch to insert mode, i will position the insert cursor to the right of your position, a to the left, I to the start of the line, and A to the end.

Relative line numbers

To fully leverage the power of the motion commands you can enable relative lines numbers.

XVim relative line numbers screenshot

With this option the line numbers on the gutter show the relative distance from the current line. This way you can move around the file using <number>j and <number>k with great ease, no need to mentally count the distance you want to jump, or to guess it.


Like Vim, you can configure XVim with an rc file, the .xvimrc. This means that you can put that file under version control, share it across your machines, and experiment on the configurations without being worried on messing them up.


Developers like to work on split windows. XVim allows you to open a new Assistant Editor any way you want, in normal mode type :sp to open a new horizontal window, or :vs for a vertical one.

XVim windows animated screenshot

The list of awesome things you can do with XVim could go on and on, have a look at the features list to get an idea. I am still a newbie when it comes to Vim, so I wouldn't be surprised if there are actually more cool things you can do that I'm not aware of.

How to install XVim

The best way to install XVim is thorough Alcatraz, the Xcode package manager.

In alternative you can manually install this plugin by following the instructions on the README.

Mastering your text editor and IDE is all about removing friction between what you want to write and actually writing it, so that you can focus on what really matters, writing good code.

Some developer consider learning how to use Vim a waste of time, it is too hard. Quoting Ben Orensetein: no one ever says “I’d love to learn Street Fighter 2, but there are just so many combos!". I recommend his post "The Vim Learning Curve is a Myth" to get convinced on why Vim is worth it.

I would like to challenge you to try out XVim, or Vim if you are not using Xcode daily, for week. Chances are you'll fall in love as I did. And if that doesn't happen, well at least you will have exercised your brain a bit by trying something new.

Want more of these posts?

Subscribe to receive new posts in your inbox.