Unified answer:
If you are using tabs
I'd try using listchars:
:set listchars=tab:\|\
:set list
note: there is a space after the last \
above.
This method is good because it uses Vim's built-in support for showing this kind of thing.
Example output:
| if (1) {
| | func();
| }
However, this doesn't work for leading spaces. As pointed out by @Josh Petrie, there is a patch to work for spaces, but then you'd have to recompile Vim, which is beyond the scope of this answer.
If you are using spaces, and don't mind using a plugin
Vaibhav Sagar points out the plugin indentLine performs this functionality.
Install in the normal way (see installing Pluginsinstalling Plugins) and it seems to magically just work without further input. If you don't mind the ASCII bars, you don't need to do anything with your fonts. Example output of your example after setting your indentation settings and running :IndentLinesReset
45 ¦ var move = function(direction) {
46 ¦ ¦ if(!initialized) { initialize(); }
47
48 ¦ ¦ if(shiftBoard(direction)) {
49 ¦ ¦ ¦ setTimeout(addRandomPiece, 100);
50 ¦ ¦ }
51 ¦ };
The plugin requires Vim 7.3 or later, and makes cleaver use of that version's Conceal feature. Instead of actually hiding text, it replaces text with bars in the view, but not the actual buffer. The result is you see the bars but they don't get saved into the file (since they are actually spaces)
Caveat
Both of these methods assume "properly" indented code. They don't place the indentation lines at the level of indent when a "block" is opened (which sublime appears to do) but instead places lines at regular intervals based on your indentation settings. Additionally, it only shows the bars on lines where there is actually space (which is why the line in the vim output under the first if
has no bars, making a visual gap)