Yehuda Katz is a member of the Ember.js, Ruby on Rails and jQuery Core Teams; he spends his daytime hours at the startup he founded, Tilde Inc.. Yehuda is co-author of best-selling jQuery in Action and Rails 3 in Action. He spends most of his time hacking on open source—his main projects, like Thor, Handlebars and Janus—or traveling the world doing evangelism work. He can be found on Twitter as @wycats and on Github.

Everyone Who Tried to Convince Me to use Vim was Wrong

A couple weeks ago, I took the plunge and switched to vim (MacVIM, to be precise). It wasn’t the first time I tried to make the switch, and I had pretty much written it off entirely.

Why? Because the past few times I tried switching to vim, I took the advice of a master vim user, and quickly sunk into the quicksand of trying to learn a new tool. In every prior attempt, I gave vim a few days before I gave up. And every time, I managed to get virtually no work done the entire time, spending about 90 percent of my day fighting with my editor (a more charitable way to put it would be “learning my editor”).

Invariably, the master vim users that were helping me make the switch would encourage me to stick it out. “If you just give it a few weeks, you’ll never want to switch back.”

The trouble was, I had work to do. I could only switch editors if the new editor did not significantly impede on my day-to-day work. I can already hear the responses: “That’s simply impossible. It’s a new editor designed for advanced users. You’ll just have to put up with the pain until you get used to it.”

Here’s the thing, though: I didn’t really have to put up with a huge amount of pain when switching to Textmate for the first time. In fact, it was downright pleasant.

The last few times someone tried to get me to switch to vim, I issued them a simple challenge. Can you tell me a way to switch that will not significantly reduce my productivity for the first few weeks. It wasn’t a challenge that was intended to fully shut down discussion. When I really thought about it, Textmate wasn’t doing all that much for me. It was a glorified Notepad which had working syntax highlighting and understand where to put the cursor when I hit enter (most of the time).

I don’t actually use “snippets” all that often, or all that many “commands”. I don’t mind the extensibility of Textmate, but I’m not a hardcore Textmate hacker myself, meaning that I’m ok with any editor that has the same level of extensibility that Textmate has (namely, all of them).

Despite what I considered a relatively reasonable request, my challenge was met with disdain and even anger by most of the people I talked to. “If you feel that way, Vim probably isn’t for you.” “You’re learning a new EDITOR for God’s sakes. Of COURSE there’s going to be a learning curve.”

I had written off the entire sorry affair.

A few weeks ago, Carl told me that he was playing with Vim. His explanation was that he had seen a number of people be really productive with it, and he was curious. Carl is definitely willing to put up with more pain to learn something new than I am, so I issued the same challenge to him.

Perhaps because he wasn’t steeped in hardcore vim hacker lore, he didn’t angrily dismiss the entire premise of my question. Thinking about it a bit more, I realized that most of the people who had tried to get me into vim had suggested that I dive in head first. “First thing: turn off the arrow keys.” “Don’t use the mouse. Force yourself to use the keyboard.”

Carl convinced me to use vim for the first couple of days pretty much exactly as I use Texmate (with the exception of having to switch between normal and insert modes). I installed NERDTree on MacVIM, grabbed the most common vim “packages”, and was off to the races. (I should note that I installed topfunky’s PeepOpen, which definitely helped with a very common workflow that I find it hard to live without).

For the first day, I clunked around by using my mouse’s scroll wheel, clicking and highlighting things, and spending most of my time in insert mode. It was slightly less productive than Textmate, but mostly in the range of what I’d expect switching to a new tool. In short, while I felt a bit out of sorts, I was able to get plenty of work done that first day.

As the days went on, I learned a few commands here and there. The first big one for me was ci as in ci " (it means: replace what’s inside the next set of " and go into insert mode). This singlehandedly made up for most of the productivity losses I was feeling from learning a new tool. Throw in o, O, A, :N and /search and I was already quite a bit more productive than I had been in Textmate.

Sure, I’m still plodding around in some cases, but only a handful of days later, using Textmate for anything feels clunky (most commonly, I try to use o or O to insert a new line above or below the one I’m currently on).

I was able to get here because I used my mouse wheel and button, arrow keys, apple-f to find text, apple-s to save files, and a whole slew of other common idioms, instead of grinding to a halt and trying to switch all of my practices at once.

To those who would say “that’s obvious; of course you learn vim incrementally”, I would simply say that having spoken to a number of vim users in the past, I never got that advice. Instead, I got a lot of advice about turning off my arrow keys, disallowing the use of the mouse, and learning the (MORE EFFICIENT!!!) vim ways to do everything, all at once. People just couldn’t stomach the idea of me continuing to use an outmoded practice (like apple-f) when vim had much better tools available just a (huge volume of) memorization away.

To those who are considering using vim, my recommendation is to use MacVIM, NERDTree, PeepOpen (or command-t), and use the mouse, arrow keys, and familiar OSX’isms all you want. Very quickly, it will become obvious that there’s a better way to do all kinds of things, and you can pile on the newly found efficiency once you’ve successfully made the switch without losing the ability to do work in the short-run.

237 Responses to “Everyone Who Tried to Convince Me to use Vim was Wrong”

Many years ago when I was first going to school to get my B.S. in CS, my teacher had the entire class learn VI on sun sparc machines. Her reasoning was that VI was available just about everywhere and something like notepad wasn’t. (I believe here real rational was to weed people out of the class.)

I used VI happily for years through my undergraduate career. When I got to grad school, there was a very smart teacher who I looked up to who used VI commands inside of Emacs with viper (http://www.delorie.com/gnu/docs/emacs/viper.html). This boggled my mind. There’s no way you can combine VI and Emacs! It’s sacrilege! His rational was that it was much easier to handle a project’s hierarchy with Emacs and it’s excellent buffer support but he liked VI’s key commands better.

Today I use Textmate a lot but still drop down to VI when mate just won’t do the job fast enough. By the way, VI on the command line rocks (set -o vi).

Guess i hear what your saying, but i think people pointed you in that direction to avoid forming bad habits that prohibit you from really learning the vim way. Nice post, but i think ill still continue to advise against arrows and mice. :D

My guess is the same is true for Emacs: Using Aquamacs enables you to use all the familiar Mac keybindings and the mouse, and switch to more powerful ways gradually.

You people need to grow a pair and start using Emacs.

http://imgs.xkcd.com/blag/rms_katana.jpg

I use vim pretty regularly in hardcore-dont-touch-the-mouse kind of way. Mostly through ssh to various linux boxes. I still use apple-s to save files when I use MacVIM on my laptop. It just feels right.

Why would you think that you’re going to learn any sufficiently difficult thing any way other than incrementally? Does one really need to hear this from a master?

Vim definitly is hard to learn. And experienced vim users know there’s no way around that startup bump. I think the advice given was well intended to make that bump as short as possible. The logic would be that going trough a series of bad vim habits in order to arrive at the good ones would take longer then taking a harder but shorter hit first.

Anyhow, I use Vim exclusively, both on mac and linux, but I prefer to use it from the console. I got started with vi about 10 years back when I started programming on solaris. We used to have a really horrible C++ IDE (Sniff+) and after a while I took to the CLI with zeal. Somebody pointed me to vi, which was hard, but it got better, a lot better fast. Stuck to it eversince.

And in case you wonder, you not the first to remark on vims rather peculiar learning curve :) http://www.accurev.com/blog/2008/03/07/editor-learning-curves/

You’re absolutely right – incrementally is the way to go.

But Vim hackers are absolutely right to some extent too – when you have a day or two, after you’re comfortable with the normal mappings, disabling the arrow keys will really help.

But for heaven’s sake, don’t switch to Vim at the expense of productivity!

Wow – I’ve been (productively) using VI for 20 years and I didn’t know about the “ci” command. I’ve always used the slightly less efficient “ct” which requires you to first navigate to the starting quote, and doesn’t work with parentheses. Thanks for the tip!

I still think you should stop using the mouse and the arrow keys.

I recommend http://vimcasts.org if you like to learn from screencasts. He brings up macros, text formatting, visual editing and more.

I guess vim is more for the true techie. I really like vim because it reminds me of editing programs on my old atari 800. The editor works in the way I expect it to. yes it takes a while to remember how to do a global search and replace but you get nice touches like being able to do a partial search and replace and nice things like that. You can use the mouse in most vim editors to copy text and then simply insert said text at the cursor position, or you can simply yank and paste. I’ve used vim for around 10 years, you had to when coding on any Unix system.

I love how Jason didn’t actually get this post.

vim is the greatest editor ever created. Your frustration in trying to learn how to use it says more about your character than the tool itself. My wife won’t even pick up a common hammer, but prefers to sneer at it in disdain while telling me to pick it up and hammer the nails in the wall to hang her paintings. lol.

One of the huge advantages of using Vim over other editors is because it is available on all systems. Whether you jump on an OS X system, Windows, or Linux, Vim is available. However, the mouse and some normal shortcuts won’t always be there. I respect what you are saying about easing into the editor. I agree to a point, but advise anyone to move away the arrows and mouse as quickly as they can. Learning Visual mode is also helpful.

Can I suggest a completely opposite approach that worked for me? I kept using TextMate on Mac, and NOtepad++ on Windows, until I am a god-like user of vim on Unix/Linux boxen.

Then, when I want to do a multi-file search and replace, I have one way of doing it (vim/gVim/macVim support the same vim commandset), but when I am not in the “vim” mode (mental mode), I don’t have to use VIM all the time. Just because it’s a text editor doesn’t mean it has to be the only one you use. Okay, so it’s great to have consistency.

But learning VI-commands on command line Unix/Linux boxes is a great way to remember and recapitulate the phylogeny (developmental history) that vim has — the command set’s origins with vi and before that, with ex). The closest modern equivalent to the origins of VI-as-an-editor-usable remotely in Visual Mode even at low bps rates like on my old 1200 baud modem, circa 1986, help you to see where it all came from.

I am glad to see that your blog wasn’t another “tried to learn something new and failed” but rather that you’re self-reflective on how you learn, and that you have realized there are more and less optimal ways to learn, for each style of learner.

For me, I learn best when presented with using a product in the context in which a product was originally developed, solving the problems first in tutorials that the product was designed to solve. To give an analogy the Cocoa book by the BigNerdRanch guy does this; It shows you precept upon precept and in a way that you can tell that this guy was around when the NextStep framework was originally developed.

W

While you use these archaic text editors for mac, on windows we have this thing called notepad++… best editor ever. The fact that everybody still uses these kind of editors you are using I find quite appalling, I am a man that values clever clean and easy to use designs (which is what mac sell themselves as, except to do this they just remove all options and configurations… and bang up the price), and I find that these text editors are so ass-backwards, counter-intuitive and lack any decent GUI that you actually have to spend a decent amount of time to LEARN them, hohoho… embarrassing!

Way to go with the misleading title. It gives the feeling people were wrong about trying to tell you to use vim, instead of wrong about how to learn vim. Congrats, you trolled well.

Also your post ended in sort of a cliff-hanger, did you dump Textmate after learning about just a few of vim’s useful commands or not?

After trying VIM for a few hours, the only thing I feel like it’s missing (coming from Textmate) are the Bundles (which are a handy crutch for less frequently used commands). Is there a VIM equivalent?

There is always the Vim Kata: http://blog.wekeroad.com/2010/05/24/vim-kata-one

These days the old-style text editors like vim and emacs are only really useful from the command line. If you’re using a GUI you should really use a GUI editor. Some good ones for the Mac are SubEthaEdit, TextMate, and BBEdit.

So true. This is how I’ve learned Vim as well. I’ve had the fortunate luck of learning Vim on my own terms, and not getting discouraged by hardcore Vim hackers. This inspires me to give Emacs another shot. Thanks.

What actually got me into vim was vimperator, a Firefox extension that adds vim-like keybindings and some advanced functionality. I learned vimperator incrementally before I took the plunge into vim. I think vimperator is a great way to get your feet wet and learn some of the vim ways, and it’s made my browsing much more efficient.

I certainly think that vim’s deep learning curve is well worth it, considering how much of my life as a developer that I spend using a text editor. I think the dilemma is very analogous to hunt-and-peckers versus keyboardists that use home row.

ci is not a command. c is the command and i” is an operator (of the text-object family). Every vim user needs to know how commands and operators work together.

I use and love vim, but I don’t encourage others to use it. It gives me a productivity advantage over others that I like. Why would I encourage others that don’t get it to be as much or more efficient than me?

@a,

Please by all means keep using notepadd++. It’s awesome that you found a tool you like. While I don’t know anything about notepad++, I can tell you why people like vim (mac users like me included). The biggest thing for me is the speed of editing with motion commands. Once you understand its modal design, these become incredibly useful. Take for instance the delete command: d. After you type d, you type the motion that specifies the what text you want to delete. So:

de “deletes to the end of the word
d$ “deletes to the end of the line
dw “deletes to the beginning of the next word
dd “deletes the entire line including carriage return
dit “deletes the contents of the tag you are currently in (This is an example of a text object)
dat “deltes the tag inclusive

And this works with most combinations of editing commands and motions. This command structure is the first thing that makes most people go whoaw, now I get why vim is awesome. Then the fact that you can immediately repeat a very complex operation by hitting the period “.”, you never want to go back to using another editor. Then when you layer good regexp support, vim scripts and extensibility (up to replicating and surpassing most features of an IDE), powerful keyboard mapping, and a strong community of vim scriptors, its just icing on the cake.

Glad you finally found a way to get going with vim. I went through much the same mindset (but on Windows/Linux), and made notes of how to do things I needed, like find and replace, etc until I learned them. I think there is a point where it just clicks, and then it becomes easy.

Before long, I found myself more and more unable to use mere editors like Notepad++, Visual Studio, etc. How anyone can think Notepad++ is “the best” is beyond me, but there’s no accounting for human taste. Obviously, he’s not a programmer, or he would at least realize the difference even if he’s not willing to invest the time to change.

I still use arrow keys, btw. It’s ingrained into my brain, and since they are now available on most any computer I use, it’s no longer a big deal. Used to be necessary when many keyboards didn’t have arrow keys.

If you like vim, and use Firefox, you should check out Vimperator, which makes Firefox feel like vim: http://vimperator.org/

Just stick with Ruby on Rails and Textmate, you noob.

I had a similar experience. In ten years of hacking, scripting and coding I managed to be quite productive without ever successfully learning vim or emacs. I finally broke through the barrier with vim recently. The killer feature that I could no longer live without was ctags – moving from function calls to function definitions across multiple files. I lost productivity for about two or three days as I hacked my .vimrc to make the tool do things like Save with ctrl-s, but the investment is slowly paying off. As you say, the key is to find a compromise between changing your habits and modifying the tool’s behavior.

I more or less agree with you here. When I started this job 3+ years ago, I was told by everybody here I really should learn vim. Being a long time emacs user and even using nano/pico for quick-and-dirty edits, I was reluctant, since what I had been using was working fine for me. Once I got over the hump of trying to actually remember all the commands (at least the important ones I use daily), it’s become pretty fluid. I don’t do lots of block editing and don’t know the more advanced or esoteric commands and their operators, but I can bang around and not get completely frustrated. Like pretty much any piece of software, I encourage anyone to use whatever works best for them in whatever situation they are in at the time. I frankly don’t understand editor holy wars and rabid fanbois of any stripe. I do use vim regularly, but I also use emacs and nano/pico and eclipse and possibly one or two others when the need arises.

I really enjoy it when people who have apparently only mastered a single operating system and/or set of tools feels justified in slamming other operating systems / platforms. For the WIndows guy touting Notepad++, yes it’s a nice tool if, as in the case of Windows, you are generally operating in a GUI environment (even on servers where it really makes no sense). There were a myriad number of shell editors (Norton Editor, VIM, etc.) that provided the same level of clean functionality as Vim or Emacs and were quite enjoyable to use.

However, your comment about Mac pricing, feature cuts, etc. is, at best misinformed or at worst, demonstrating your own ignorance of other environments. One of the chief complaints that I hear and have experienced with Windows software is the high degree of bloat due to Microsoft’s tendency to add features that most people never need or use to justify pushing an upgrade. That’s their business model, but to be honest, few people use all of the features on anything approaching a regular basis but there is no way to turn them off to save memory, load times, etc.

The moral? People who live in glass houses shouldn’t throw stones.

Have a nice day! :-)

Even after using vim exclusively for years, I try to learn one new movement or change command a week, and abuse the hell out of it. If it was actually useful, I’ll have memorized it within that week!

Also responding to ‘a’… I fell in love with Notepad++ for a while, but Vim made me quit. Notepad++ is very good, but it seems awfully powerful only when all you’re used to are other conventional Windows text editors — compared to Vim it’s relatively slow and limited.

Maybe it’s just Vim changing my mindset, but what seems odd to me *now* is creating a syntax file through an interface that presents you with limited choices despite multiple screens, and then finding one day that all your work on your custom syntax simply disappeared (as compared to writing unlimited syntax rules in a text file that can be easily copied).

Vim’s operation is also a lot more stable than any “real” Windows text editor I’ve used. I was keeping lists of Swedish words in N++, and would cringe upon reopening my file to find that all my umlauts had been zapped into plain characters, and it didn’t matter what kind of encoding I used to save it. Again, lots of work irretrievably lost!

These are minor annoyances, and I wouldn’t recommend against N++ for light text duty and general HTML/coding, but I can see why serious, efficiency-conscious coders would opt for the power and stability of Vim and Emacs.

@a: award for dumbest comment

I use the mouse wheel including:
arrow keys
home
end
page up
page down

Those keys were created of a reason.

There’s never a wrong way to do something as long as it helps you accomplish your goal.

Bit of a shame, if you were going to make a switch you should have gone for emacs. But hey its not too late. Emacs is trivially easy to use. Now whatever you do, don’t use your mouse or the default key bindings, just dive right in and remap everything straightaway so you won’t get confused by any of the documentation (I mean come one does anyone ever really RTFM? Pa’ lezzzz. You’ll be up to speed and more productive than ever in …

If I could find Textmate’s command-shift-f for either an open directory of files or a project of files assembled from various locations in the file system then I’d be into Vim.

Tried many times and failed.

After coming across this tutorial, everything became a lot more clear:
http://www.vi-improved.org/tutorial.php

Haven’t turned back since, but now I want to learn and use emacs, which appears to be an impossible feat when you have work that needs to be accomplished.

I’m surprised no one has ever suggested vimtutor to you. When I first started using Vim, this is how I learned. After I completed it the first time I was at least comfortable enough with vim to switch to it as my primary editor. I make it a point through vimtutor every now and then and every time I do I get faster and more proficient.

I think it’s already installed on Macs, just run vimtutor from the shell. I want to say it took about an hour to go through the first time for me.

Hi Yehuda, I would love your feedback on my open source book on Vim – it’s designed for taking a person from beginning to expert — http://www.swaroopch.com/notes/Vim

There is a packaged called Cream which serves exactly this purpose: http://cream.sourceforge.net/

@William MacKay…
Before handing out your sage advice, I suggest you actually have some clue about the subject. For example, do you even know what vim is? It’s normally as much of a GUI editor as you need, if you’re running under a GUI like Windows, Gnome, GTK, etc. You can choose the font, use a mouse, etc. Fortunately, it’s not a word processor – is that what you mean by a GUI editor? How “GUI” do you want an editor vs a word processor anyway?

Really – don’t give advice about things you don’t understand… seriously.

Most developers know the basics of VIM, enough to edit a conf file, but most stay there, unaware of the power and beauty of vim. At OpenSky one of the developers I worked with took a similar plunge. I put together this blog post to help him transition. http://spf13.com/post/vim-crash-course

I started with ‘ed’, the non-visual innards lurking within ‘vi’.

I take it the many tutorials that google returns for the query ‘vi tutorial’ were insufficient for you.

I prefer emacs, now, but know how to use vi / vim. When your Solaris system crashes and /usr/bin is not available, knowing ‘ed’ may be critical … well, that was 10 or 15 years ago, uphill both ways in the snow. The first time I started emacs, I couldn’t figure out how to kill it … I wound up using ^Z to put it to sleep, ‘ps’ to find the pid, and kill. But eventually I found the tutorial, having heard that I could run the C compiler from withing emacs, and use a simple command to go from an error message to the appropriate location in the right file. Motivation got me over the hurdle.

I disagree with the assertion that the speed at which you can manipulate text is a large determiner of “productivity” in a software project.

It’s exactly like learning dvorak. Would you say every person who tryed to convince you to use dvorak was wrong? :)

@FD

Yes, when you use vim, using those keys and the mousewheel is wrong. It is wrong because vim is designed to keep your hands in a typing position. The idea is that removing one hand from the typing position costs time. It costs time because issuing a command from the typing position is very quick when compared to letting your hand seek out another position, do its job, and seek back to the typing position. It can be demonstrated that vim users who have internalized the modes and shortcuts are vastly much quicker at navigating, reading and writing code then users of editors who think it’s a smart idea to make a programmers hands flutter around randomly all over the workspace.

For snippets you should try snippetsEmu.vim. Very easy to create new snippets:

exec “Snippet D ”

you can call this by pressing D[TAB-key]

Macros are also very easy to use in my opinion.

Also you should check out the V command for me a reason not to switch to Textmate.There is a nice short video tutorial http://vimcasts.org/episodes/selecting-columns-with-visual-block-mode/

Now… as you see, all those people who tried to convince you to use Vim were right. However, I should warn you that all those people who are trying to convince you to use Emacs are wrong.

In short, developers you must know vi so they can navigate/and address issues in the worst of cases when no other editor is available, especially on UNIX/Linux environments. While vi is not my preferred editor, it has saved by neck many, many times and I still use it all the time in UNIX/Linux env.

ceo

Leave a Reply

Archives

Categories

Meta