:: I’ve Switched From TextMate to Vim (September 24, 2010)

Skip to main content
Newer: Signs of Life Older: Funny MMO Clan/Toon Names

I’ve Switched From TextMate to Vim

I’ve been using TextMate for a long time. It’s a great text editor that introduced a lot of really cool features like snippets and bundles. It is missing some features that I would consider standard though. Things like code folding and split windows. On top of that, TextMate 2 has been promised for the last few years and nothing has materialized.

I’ve tried out other editors before like BBEdit, jEdit, Coda and even plain ol’ TextWrangler, but I would always go back to TextMate after a week or so. Nothing seemed to be as slick or powerful as TextMate. I began to both love and hate TextMate for this. I knew I wanted something better, but there wasn’t anything I knew of that fit the bill.

Then I tried Vim. Actually, let me back up. I had tried Vim once for about 5 minutes a long time ago. When it first opened up, I tried typing and nothing was happening! I thought it was broken or installed incorrectly, so I dumped it and went back to TextMate.

Eventually my desire to find another, better editor came back a few months ago and this time I decided I wanted to really figure out this Vim creature people were cooing about. I learned about its different modes, and how you needed to be in insert mode in order to actually write your code. I couldn’t figure out why Vim’s normal mode wasn’t like every other editor I had tried before. I just want to write code, please! Then one day it finally clicked what kind of power Vim’s normal mode gives you.

Writing actual code is only a part of the whole coding experience. A lot of the time, you’re copying/pasting, fixing errors, jumping between files, etc. In an editor like TextMate and most others, you use your mouse and scrollwheel to move around, make selections and so on. This requires more hand movement than is needed.

A very simple example, say I wanted to move a line of code from one place to another. Say I need to copy line 60 to line 90. In TextMate, I would move my hand to my mouse, possibly use my scrollwheel to get to the area I want, move the mouse pointer to the line I want, triple click, then type Cmd-C, then click on the line I want to paste it, then type Cmd-V.

To be more fair, TextMate does have keyboard commands for this too. So to jump to a specific line, I type Cmd-L, then 60 and hit enter. Then type Cmd-Shift-L to select the whole line. Then type Cmd-C to copy it. Type Cmd-L, then 90, then enter. Then Cmd-V.

In Vim, in normal mode, I can jump to the line I want by typing :60, then type yy to yank (Vim-speak for copy) the line, type :90 to jump to the line I want to paste, then type P. It’s similar to TextMate here, but fewer keys and hand movements are needed. 17 keys for TextMate vs 12 for Vim (counting needing shift to get : ). With keymapping in Vim, that number can be even lower.

This is a simple example, so Vim isn’t that much quicker than TextMate here. Vim really starts to shine when you require much more complex movements and text manipulation. Plus it supports the two features TextMate still doesn’t after all these years: code folding and split windows.

When I first started using Vim, I was clumsy and made mistakes left and right. I couldn’t remember many of the basic movement keys, so I just stayed in insert mode most of the time. Every now and then I would venture into the scary normal mode. I’m sure a Vim jedi would’ve cringed if they were watching over my shoulder, but I kept at it and steadily became more comfortable and familiar with it.

I’m still not at the level a long-term Vim user will be at, but I’m definitely faster than I ever was with TextMate. You get spoiled really, really fast with normal mode and movement keys. I get pissed when I can’t use them in other apps. I’m forever trying to use Ctl-F/B in my browser.

I’ll wrap it up here by giving a few tips and pointers for those moving from TextMate to Vim.

First, download MacVim. It’s much more Mac-like and easier to use than Vim in the terminal. You can use Cmd-C and Cmd-V for instance, which eases the transition from another Mac editor to Vim.

Second, remap Ctl to your Capslock key. I never use the capslock key, and it’s much easier to reach with your pinky than the bottom-left ctl key.

Third, install these plugins:

A much easier way to manage your Vim plugins.

Uses ctags to create a list of all variables and functions in your currently viewed file, and lets you quickly jump from one to another

Gives you a directory tree you can nagivate through using either your keyboard or mouse

Makes commenting code quicker and easier

Mimicks TextMate’s snippets functionality

Makes surrounding code with various tags or brackets quicker and easier

Vim’s a bit different with how it handles copy/paste. YankRing makes it much easier to paste something you might have yanked a few changes ago.

Fourth, watch Derek Wyatt’s Vim screencasts, especially the beginner ones. Derek is easy to follow and listen to, is enthusiastic about what he’s showing you and knows his stuff. I learned a crap-ton of stuff just from his videos.

Fifth, bookmark these sites:

Vim Wiki
Vim Scripts
Jeet Sukumaran

Sixth, do a Google search for “vimrc”. Check out what others are doing with their Vim config files. You can pick up some really handy settings, tricks and time-savers this way. I would highly recommend changing your leader key to “,” and mapping “,e” to edit your vimrc file. “,s” for quick reloading of the vimrc file.

Seventh, download and print out this Vim cheat sheet. I can’t tell you how many times I’ve used it over the last few months.

Lastly, don’t give up! Vim has a notorious learning curve that has defeated a lot of half-hearted forays into Vimland. Once you get over the initial hump, and you finally grok the power of Vim, there’s no going back.

Bob S's gravatar Bob S United States September 29, 2010

Just curious whether you’ve ever tried emacs. I suspect at this point you’re already too addicted to vim to be swayed by anything else, but thought I’d ask.

Chris's gravatar Chris United States September 29, 2010

I tinkered with it for about 5 minutes. I didn’t like how many key combinations I had to use to do things that were much easier to do in Vim. Plus I don’t need all the power that emacs brings to the table. I only need an editor, not all the other myriad of things emacs can do. Vim is smaller, launches faster, is easier to use (in terms of keystrokes) and I’m already used to it.

Do you use emacs? If so, what would it offer that would make me want to give it another shot?

Renata's gravatar Renata Sweden October 9, 2010

Hi Chris!

I was reading old messages from 2004 about Tengwar. Do you know how to translate? Because like most of the people I want to get an tattoo smile
If u know how to do or have some other ideas of who or where I can get my translation so please send me an email on


Chris's gravatar Chris United States October 12, 2010

Sorry, Renata. I haven’t worked with Tengwar in a few years. I wouldn’t want to give you bad information for something so permanent.

I’m also not sure who is still around in the Tengwar world that could give you accurate info.

Sorry, I wish I could’ve been more helpful.

Derek Wyatt's gravatar Derek Wyatt Canada February 17, 2011

If you actually know it’s line 30 and 90, this can actually be even faster than what you’ve written by using good ol’ vi/ex commands:

:30t 90


Now, knowing the 30 and 90 isn’t always realistic… a lot of the time what you need is to move / copy a line to the bottom of the file, or the top.

:30 t 0 # copy line to top
:30 t $ # copy line to bottom

You may also not know it’s line 30 very easily, so you can ‘:set number’ to turn on the line number column to help you out.

Even more common is that you want to do this on the current line, so…

:.t $ # copy current line to bottom
:.move 0 # move current line to top

Now, imagine you want to move all of the Makefile dependencies that look like this:

target.o: source.c header.h

to the bottom of the file… but, they’re scattered all over the damn place in the file. Here’s how you do it:

:g/^\w\+\.o:\s\+/move $

The regex may not do exactly what you need depending on what the file actually contains, but… you get the idea.

Chris's gravatar Chris United States February 17, 2011

Very cool! That’s one of the things I love about Vim: I’m always learning some cool new thing it can do.

Thanks for sharing, Derek. And thanks x100 for your awesome videos.

lebisol's gravatar lebisol United States April 28, 2011

No matter how many times I tried Vim I just could not digest its lack of color coding.
I still don’t understand how typing this:
:30 t 0 # copy line to top
:30 t $ # copy line to bottom

is faster than spinning a mouse wheel and doing copy-paste key strokes. Perhaps its shine comes out when doing complex text combing but as an editor for most of my interest in xhtml,css,php….

How does it play along with EE or CI syntax?

Chris's gravatar Chris United States May 6, 2011

Lack of color coding? Do you mean syntax highlighting? Are you talking about in general or for a specific language?

The vast majority of my editing is in HTML, CSS, JavaScript, PHP and MySQL as well. For simple copy/paste exercises, TextMate or most any other editor will be just fine and you won’t notice much of a difference. It’s when you get into larger files and need to do more complex operations that Vim begins to shine. I can find my way around a large file faster in Vim than I can in TextMate. Not to mention other features like code folding, split windows, etc.

lebisol's gravatar lebisol United States May 6, 2011

Right the syntax highlighting and my editing is the same but yet to find the need for ‘power’ that vim has. Don’t remember its quality for code folding.
I use the WeBuilder and notepad+ for quick and dirty edits.

Your name is mandatory
Your email address is mandatory
Your comment is mandatory Formatting:
-deleted text-
   What word do you see to the left?
The captcha is mandatory