Programming ≈ Fun

Written by Krešimir Bojčić

Smooth Sailing of a Vim Renegade

Do you love Vim? Do you love modal editing and motions?

Do you hate terminal Vim not playing nice with OS X? (copy&paste problems). Do you hate Mac Vim occasional slowness(and OCD is making it worse)? Do you hate not being able to see the project tree that looks decent? Do you hate having to compile Vim to the specific version of Ruby in order to make the Command-T plugin work?

Even though the hate list is way bigger than the like list, modal editing is such a big deal for me that I was coping with everything else.

Ever since being exposed to modal editing I have fallen in love with the concept. I occasionally tried new editors, but never too seriously. Don’t get me wrong, the last three years with Vim have been a lot of fun, but now I feel it is time to move on to greener pastures.

Tool of choice is called Sublime Text 2, and to be honest all hype around it was a bit of a turn-off.

My first try didn’t go very well. The vintage emulation mode (basic Vim motions and command) seemed broken, for example if you press key ‘j’ and hold it, the cursor goes down just once. Since I am relatively new to the whole OS X thing, I didn’t know that it’s related to the OS X and not something connected to the editor itself. Therefore I ditched it, and tried to forget how fast and polished it looked.

After a while I’ve fixed the OS X issues and gave it another shot.

defaults write com.sublimetext.2 ApplePressAndHoldEnabled -bool false

Modal editing(Draw)

My Vim skills are modest (but I like to think differently). This is basically covering my needs and I’ve found all of it present in the vintage emulation mode.

Command-T plugin(Sublime wins)

It works as fast as the Vim plugin. Selection is better because you can see the file instantly while choosing which one to open. The Cmd-P command was mind-blowing for me since it allows me to navigate over methods and stuff. It is almost like working in a Smalltalk image and hopping around.

The best part? The darn thing JUST works.

There is no source code downloading, no blog posts about how to compile it and no segmentation fault.

Cmd+T - just works(©)

Navigate symbols:

Cmd+P
@

Project overview(Sublime wins)

Sublime has a TextMate-like tree view overview of a folder. I was embarrassed to see all those .swp files hanging around. Also since I turned on persistent undo there have been a tonne of .un~ files.

After fixing it:

find ~/project/ -name '*.un~' -delete

I was able to glaze at how nice my project looks, while admiring my brilliant and world changing code at the same time.

While on the subject of .swp files. I was always curious as to whether I should recover or delete (and whether it even matters?). All in all it gave me nothing but grief.

I am aware this .swp files issue is fixable but since Vim is so ubiquitous it was a lost battle(like Windows “take tour” and IE “welcome to tabbed browsing” kind of a thing).

Running tests from editor(Draw)

There is an RSpec plugin that works nicely. It’s better than Mac Vim, but is worse than terminal Vim.

:map :w\|!rspec spec<cr>

I am looking for a way to run full specs while running bundle exec when needed (no luck yet).

Spell checking(Vim wins)

Sublime is using Hunspell.

F6 - spell check
Ctrl+F6 - next error
Ctrl+Shift+F6 - previous error

Since there is no way (that I know of) to get suggestions with keyboard shortcut I find the spell check to be inferior to the Vim counterpart. On the other hand if you start mouse-clicking around it’s not such a bad experience.

Package management(Sublime wins)

Sublime has an integrated package management that is really nice compared to what you get out of the box in Vim. Details are available here.

Alternate files(Draw)

This is great for switching between test and implementation code. It’s possible in Sublime with:

Cmd+.

Conclusion

Every time terminal Vim messes up my copy&paste buffer I die a little. Every time my terminal Vim breaks the terminal buffer I die a little. I still love Vim. It’s just that I got tired of massaging it to work exactly how I would like. That whole setting-up-to-make-it-work-dance started reminding me of a “Linux audio card problems”.

So am I really a Vim renegade? No I don’t think so. I feel like Sublime is a better version of Vim. I know everybody says that Sublime has its own character (which it does), but I look at it as a faster, easier-to-extend and good-enough Vim without the historical baggage.

So even if you are a hardcore Vim user you may like Sublime. At least it doesn’t yell at you for pressing:

:w

On the other hand, if you are using vanilla Sublime and have never worked in Vim, you might wanna try vintage mode or even the Vim itself.

Comments