Reno, NV    +1 (800)0 621-0871

Go back

Development

Simplest things in life: Vim

  |  August 8, 2011

Not trying to start editor wars here, but changing from TextMate to Vim was one of the best things that have happened to me. Recently, I was investigating a bug involving something about a ruby script that’s 1000 lines long. I didn’t have access to the original file so I had to create a 1000 line ruby script.

My first try was to create a ruby script that will print out 1000 lines using puts. This was easy, with File.open, although I still had to format etc and took me about five minutes.

Enter Vim.

I had to rewrite the code by not using puts and using a real, non-cpu extensive ruby line that will just check if text exists in a browser. Instead of writing a ruby script again, I remembered about Vim’s power. To cut the long story short, all I did was yank the line I wanted to execute 1000 times(can’t do a loop since the bug was supposed to have happened because the script was 1000 lines long) and then just typed:

1000p

which basically just pastes the line 1000 times. Trying to think about that in TextMate without any plugin, I would have had to do an exponential copy-paste, where I duplicate the line, copy the two lines, duplicated the 4 lines, etc.

It would have took me more or less 5-10 minutes also, along with just writing it in ruby which would take about 1-3 minutes. Vim did it for me with just 5 key presses which roughly translates to 1-2 seconds.

Sweet stuff is sweet.