Journey into the World of Vim

I used to make it a part of my day to learn a new tool or find a shortcut for something I already did. It's a habit I got out of for awhile. I called it my laziness: I don't want to spend time operating a tool; I want to spend time building what needs to get built.

In my heyday, I'd have my machine customized to the nines. Lots of shortcuts and gestures and bells and whistles to help me be productive. It was always awkward to hop onto somebody else's machine because I'd instinctively attempt to use a shortcut and it wouldn't be there.


When I switched to a Mac about three years ago, I kept it fairly minimalist. Yes, I had a bunch of new tools to learn. I had settled nicely into using Textmate as my main day-to-day editor. It's a perfectly reasonable editor with lots of great features. I used ProjectPlus, Zen Coding, and a couple other plug-ins. Textmate is a decent application and is easy to get started with. It's like most other text editors: cut, copy, paste with a number of handy options available at the click of a mouse. Expertise in the application grew as I learned a few more of the keyboard shortcuts within Textmate.

However, in my current job, I found my time split between working locally on my machine and needing to be logged into a remote server making to review and test changes. Sure, I could work locally and just copy the files back and forth. And this is exactly what I did. For awhile.

First introduction to Vim

I knew of Vim and would occasionally use it when working on remote servers. Edit an Apache configuration file here. Make a quick change to a file there. I first learned of Vi (of which Vim was born from) back around 1991 when I did a co-op placement and found myself in front of a Unix box.

I learned enough to know how to open a file from the command line (vim filename.ext), edit the file (a to go into insert mode), save it (:w), and then exit (:q). My skill with Vim really hadn't evolved in the 20 years since I first learned of the editor.

Diving in deep

I knew Vim could do more—much more. And so I decided to take the leap and make it my primary editor. I installed MacVim and then watched these great screencasts by Derek Wyatt to get started.

The screencasts are a fantastic place to start because they focus on the core pieces of Vim that you need to know and will quickly pick up steam:

  • Movement
  • Editing
  • Buffers
  • Windows

The first three are really the key ones. Movement is important because a lot of the power in Vim is being able to move around a document quickly. Wyatt's screencasts cover the basic movements well. From there, having an understanding of how to get into Insert mode is helpful (beyond hitting a, like I used to do).

Buffers are really where it's at. A buffer is like having a document open in another editor. Except it's just sitting there in memory, waiting to be worked on. By default, you only see one document at a time. I used to have to save, exit out of Vim and then open another file to make changes. This is very tedious. I just didn't know any better. Once you discover how to have multiple files open and to switch between them, you're well on your way to using Vim as your primary editor.

Understanding buffers is just the first step to working with multiple files. The next step is to manage those buffers in a visual way. Two ways to do that include Windows and Tabs.

Tabs are a familiar paradigm. MacVim supports them much like tabs in any other desktop application. Hit Command-T and voila, you have a new tab. That new tab has access to the same list of buffers as all the other tabs. It's just a visual way of separating your work. Terminal-based Vim sessions can also do tabs.

Windows, on the other hand, are different than what you might expect. They're actually more like panes. A screen can be split into multiple panes. They can be split horizontally and vertically and split multiple times.

You might want to check out the NERDTree plug-in which provides a browsable directory view, similar to ProjectPlus. NERDTree uses windows, so an understanding of how windows work will help you more readily use the plug-in.

Diving deeper

Since that time, my knowledge of Vim has continued to increase. I'll take time with a set of features, like tabs and windows, and work with them until they start to become second nature. Then I'll learn a new feature and continue on from there.

After the screencasts, I've gone on to learn how to customize my interface, such as getting a status line that I like. My vimrc file, a file that stores Vim preferences, is getting larger as more and more tweaks go in. It now handles indentation using the approach we have at work (four spaces instead of tabs). These are small things, I know, but I feel like I'm getting back into old habits—good habits: I'm customizing my environment to get the most out of it. As a result, I'm feeling more productive. I feel like I'm getting more out of my tools.

Yesterday, I took time to learn about code-folding (a feature that I, admittedly, have used very infrequently in any editor that I've used). Today, I was told to look into autocomplete, and so I did. Now there is a feature I will use heavily. Going back to plug-ins, I installed Zen Coding for Vim, since I find it quite handy. I mapped a handy keyboard shortcut for it, tweaked some of the snippets, and bam, I'm getting stuff done! I even wrote this blog post in Vim.

All in!

I have undoubtedly become a Vim convert and will likely use it for years to come. Yes, the learning curve is steep but for me, it's been worth it.

Published February 13, 2011
Categorized as Other
Short URL:


27 Comments · RSS feed
Gregory Gaskill said on February 13, 2011

My full-time editor progression: Gvim on Linux to TextMate on Mac to MacVim on Mac. What I missed from TextMate was command-T to open a file, and snippets. Luckily, the amazing Command-T plug-in and SnipMate exist, and work wonderfully.

Francesco Levorato said on February 14, 2011

I recently switched to MacVim from nothing less than Eclipse (I am a php dev).
The best thing I feel when using Vim is that I can /program/ it to my likings, adding shortcuts like the ones I was used to in Eclipse.
You can make it behave like you want and feel great!
Janus helped me in the switch as it gets you a decent MacVim without getting crazy in hunting for plugins
Thanks for sharing,

Scott said on February 14, 2011

It's funny, I've used Vim a lot and seen a lot written about it, but I've never seen *anything* that is actually easier or quicker to do in Vim.

For example, deleting a line is "dd" in Vim. In other editors it's simply Shift+End, Delete (or Ctrl+X). Technically Vim is fewer keystrokes (assuming you're already in command mode - and can remember the command!) but a regular editor is always more intuitive and quicker.

The one I see a lot of is, "oh but you can delete 20 lines instantly with :d20". But how do you know you need to delete exactly 20 lines unless you sit and count them? With the mouse you can quickly select the section you wish to delete. Or hold Shift + Arrow key.

Even movement is quicker using a combination of dragging the scrollbar, Ctrl+Home, Ctrl+End, PgUp, PgDown, Ctrl+G, Ctrl+F, etc...

I don't mean to sound like a troll, but I am genuinely interested in how and where Vim is quicker because I don't see it!

Tim McCormack said on February 14, 2011

Unclosed parenthetical in "First introduction" is really bugging me!

Nate Klaiber said on February 14, 2011

I made the decision to switch a few months ago. I had to force myself to just do it. Up to that point, I knew the basics. My main reason was that I found myself doing a lot more server related tasks, and I wanted to be efficient while editing in the server and moving around. It's why I wanted a barebones setup of VIM - I didn't want to switch and have so many dependencies.

The only problem I have now is that I want to navigate in all text editors with H,J,K,L.

Scott - I can honestly say VIM is much quicker than working with something like TextMate. I used to think the same thing - my colleagues all used VIM, and I was the only one on TextMate. Over time I started to see how efficiently they used their screen, buffers, and a few custom mappings - and I was blown away. All of that without ever touching a mouse.

Karl G said on February 14, 2011

> I don't mean to sound like a troll, but I am genuinely interested in how and where Vim is quicker because I don't see it!


If you're just using basic commands, vim isn't that much faster. You get the big gains with the compound motion commands (f/t), text objects (i/a), and repeat (.).

Jonathan Snook said on February 14, 2011

@Tim: fixed it! :)

@Scott: I definitely recommend you watch the first couple screencasts that I linked up. They're all about movement, which is where you'll see some of the moves. <kbd>:d20</kbd> isn't a move that I use very often, and demonstrating such isn't a huge selling point, I'll give you that. :) Getting to know some of the other movement commands like ^, $, } will help you start to see the power.

For example, if I'm in a function and I want to select the function, I could start at the beginning, switch to Visual Line mode with Shift-V and then } to select to the close bracket. x to cut it. or c to cut it and go into insert mode. I could cut it to a specific clipboard using "ax, grab something else with "bx, and then paste from either of those clipboards using "ap, "ab.

As certain movements become second nature, it just becomes much quicker to do things without having to shift your hand to the mouse and back. With that said, using MacVim means I don't have to give up the mouse altogether. There are times where I still feel more comfortable using the mouse. But the more I practice, the less work my mouse gets (and the longer the batteries last! :)).

Jonathan Snook said on February 14, 2011

And thank you, Karl. Now I know about % and will use that frequently!

Karl G said on February 14, 2011

There is one trick to %: it searches forward for a match. If you have |foobar(xyz) (| is cursor) d% will delete the entire function call.

Matt Alexander said on February 14, 2011

Thanks for letting me know about Derek Wyatt. I can tell I'll learn a lot from him.

ralcus said on February 14, 2011

i've been learning Vim the last few weeks too. I'm a dreamweaver user :-\ on windows. I felt like there had to be a better alternative and i was searching around for a textmate like program for windows. A couple of weeks a go i happened to nose in your delicious bookmarks and clicked on one of Derek Wyatt's screen casts. It convinced me enough to give Vim a good try. So far i'm enjoying it although i have to admit its a tough transition for me. But i'm persevering.

Yannick said on February 14, 2011

I have started with Vim a few month ago, after using a mix of texMate, BBedit and Espresso depending on how I felt on the day. I fot started with Dan benjamin screen cast which i really recommend. But now i can't live without "learning Vi and the VIm editor" from O'reilly . Best geeky book that I have ever bought and full of crispy Vim knowledge nuggets.

It's an editor quite challenging to learn but the reward is really worth it :) I really love the surgical precision that one can reach while editing code.

Some of the most useful plugins for me are the Tim Pope collection (surround, ragtag, fugitive),unimpaired, bufferexplorer, zen coding that I now use more than the snipmate bundle equivalent.

My best vim tip of the day is ctrl+o while in insert mode. it take you back to normal mode to issue command and switch back to insert straight after. Pure little gold gem.

Good learning!!!

redwall_hp said on February 14, 2011

I use TextWrangler for 90% of my text editing, and nano when I have to edit something over SSH. I pretty much despise command line text editors, no matter how much people rave about them. (I still can't believe there are weirdos who do *all* of their editing in vim or emacs...) I purposefully use nano because it's the least needlessly arcane.

Enrico Teotti said on February 14, 2011

@scott, I have :set relativenumber as a shortcut so I can switch the regular line count to be relative to the current line. That way you can do the :d20 or even 20j (to move down 20l)

I don't think that's the reason I am on vim tough :)

Like yannick I'd recommended and the oreily book

dr. Hannibal Lecter said on February 20, 2011

Jonathan, welcome to the dark side!

You may also like ggVG as a shortcut :)

One thing I like a lot is getting an error from PHP/Ruby etc.. "There is an error in file ZZZZ on line XX" because you can simply do XXgg in Vim and you're on line XX in your file. Quite handy, wouldn't you say? :)

Also, see this for some kick ass tricks:

SteveM said on February 22, 2011

vi is a very rewarding editor to use and the reason some people don't like it is they're not prepared to put in the effort to learn it. Unlike editors that are "easy" to use from day 1, you can really get fast when you're proficient in vi - the "easy" editor will always be slower.

The first thing you need to do is to ":map g 1G" so a single lower case 'g' will take you to the top of your file (as a single upper case one takes you to the end). Then learn how to move the cursor along the line using 't' and 'f' (and their upper case reversals). And it's a word processor, too! Use brackets, '('and ')' to take you to the next and previous sentence! You have to end end sentence with a period followed by two spaces or a newline, of course. :-)

Dave Allen said on February 23, 2011

You'll love this then:

andy said on February 23, 2011



I guess I shouldn't laugh, I used to think I was efficient in Notepad++. Things are more "intuitive" for you in other editors because you don't know how to use VIM. I especially like your PgUp/Home examples. You need to embrace the Vim mentality of keeping your fingers on the home row. Reaching over (and probably having to look at your keyboard) to hit PgUp is a huge time waster. And god forbid use the mouse.

Things that are actually faster in Vim? Well, pretty much every command

- gg/G jump to start/end of file, reaching over to home/end is a productivity killer
- ci" / ca" change word inside quotes
- I / A - insert at beginning or end of line
- / simply the search command, instant find-as-you-type search without a disgusting dialog box appearing OVER what you are trying to search for
- dd delete line and copy it to yank buffer, definitely faster than other programs
- Ctrl+O jump backwards through lines that you edited
- cw/cW/cB etc delete the current word, copy it to yank buffer, and go into insert mode

Once you actually learn the power of VIM you won't switch to another editor. There are thousands of extremely useful commands, making mastering VIM a new learning experience every day. In fact check out to really boost your efficiency.

@Stevem what? gg goes to top of file fine.

Reinier Sierag said on February 23, 2011

Hi, in my daily work as a programmer and webdesigner at an isp I'm working on different projects on different servers. I used losts of different editors the last 6 years, from dreamweaver, to eclipse, textmate and learned about VIM the hard way :). I discovered Coda a year ago. The problem with VIM is that you do not have code completion, project viewer (explorer style) a.d oplossing files for example. Also working on different projects on different servers Coda will let me switch mutch faster (sftp). Ps I think everyone must give VIM a change before sticking to a Textmate like editor.

Reinier Sierag said on February 23, 2011

(edit) oplossing = uploading

Amadeus said on February 24, 2011

I really liked vim's commands a lot, and with each new command I really grew faster (d motions!!!).

However, as a jr. front end developer and general newbie to vim, it was unsuccessful for me ti set up vim so that I could even install plugins on vim, ie zencoding, command-T. The directories and vimrc just weren't linking up in some way, and I have to say, there are a supreme shortage to tutorials for setting these take-for-granted root directories and linking them up. I just keep seeing install to your ~/.vim/plugins folder and it works, or just add to your .vimrc and it works. No dice for me so far.

RV David said on February 24, 2011

When I had first started using vim, a vim document/script with lessons/exercises formatted to get a new user familiar with with Vim's features called "vimtutor" was key.

Anthony Clark said on February 28, 2011

This post and site just got a glowing review in 'The Dev Show' #37 by

James Childers said on March 01, 2011

vimtutor FTW!

judev said on March 03, 2011

Check out if you haven't seen it already, it's quite RoR focused but a great starting point for a custom .vim setup whatever your situation

Tommy Bollman said on March 05, 2011

I have been using Vim to and fro for several years dating back to about 1990.
Vim is great for a lot of stuff. I have however realized that no single editor is perferct and that no one ever will be.

I now depend on BBEdit, as an all round editor both it and TextWrangler (which is free) is reachable from the command line.
You don't have to learn some arcane version of lisp in order to customize it. -It is not perfect, but it takes care of most of the business in a pleasant way, like programming, editing websites and latex documents, It has a whole range of plugins.
During the usage of three years I bet I haven't customized it for more than 10 hours.
You get pre built plugins for version control, syntax highligthning and such.
BBEdit even has palettes where you just embed some selections, or drag them into your document. It also updates a whole website on request when you have changed your persisten includes.

I guess I have spent far more hours with vim rc.

Jesse said on March 05, 2011

Geez, just when I thought switching from Dreamweaver to Expression Web to Notepad ++ was gonna do the trick, I come across this. Stink!

Sorry, comments are closed for this post. If you have any further questions or comments, feel free to send them to me directly.