Programming ≈ Fun

Written by Krešimir Bojčić

Favorite Vim Tools & Tricks

I’ve been using Vim for the last two years. It did take some getting use to, but the idea clicked almost instantly. Having normal and insert mode is superior concept in my mind. It allows you to treat text editing as a game.

I am not a power user by far but I do have some favorite tricks.

Using console version

  • Pros:
    • Console output is colored
    • Ctrl-y puts you to console, fg puts you right back
    • No need to open console in another window
  • Cons:
    • Color scheme is a bit uglier (less color in console)
    • Copy paste is a bit harder (from other GNOME apps, at least for me)

I’ve tried everything here. Rationally I thought that the console version is too ugly. BUT I noticed that I type vim from terminal unconsciously. The Ctr-y/fg combo and ability to start test to console from within vim sealed the deal. Somehow I got use to lack of prettier color scheme.

Running tests from vim

map ,t :w\|!rspec spec %<cr>

This combined with sub-second testing is really nice.

While on the subject, when doing one time scripts this is rather fast way to run script:

map ,r :w\|!ruby %<cr>

You are always ,r away from the results.

Using Command-T plugin

Much better than fuzzy finder. I am not even going to talk about “tree” explorers of any kind. Command-T is really really great. If you haven’t I urge you to try it out right now.

One gotcha is that if I create a new file I need to refresh my Command-T index, and CommandTFlush is just the right way to do it

map ,f :CommandTFlush<cr>

Using $MYVIMRC global

When tweaking .vimrc configuration file I can use $MYVIMRC global. It’s customary that you want your changes to take effect immediately

:so %

Using % for current file

When running tests I usually map to the spec I am working on. It’s not as much work as you would think and it enables you to run tests from wherever. Still sometimes it is nice to reference “current” file and % is a way to do it.

Yank the line without moving cursor

This one is super simple yet it eluded me for quite some time. For example if I am on line 40 and want to copy the content of line 28


Than ESC and p to put it. Talking about ESC I did try to switch ESC with CAPSLOCK. Didn’t find it particularly cool.

Switch between buffers


Toogle buffers


Alternate file (rails.vim to switch between spec and working class and some other combinations)


rails.vim of course Tim Pope is a true hero for this. (Also fugitive.vim is nice wrapper for git, but having easy access to the console lessens the need for that plugin.)


I like the desert theme. Also yesterday I saw a cool terminal emulator secret geometry. They basically disregarded the last 20 years of progress in screen technology.


That pretty much wraps everything I had in mind. I admit that you need some love for console version and vim in general. But I feel you get payoff relatively fast.