Blog

spacer

spacer

Yehuda Katz is a member of the Ruby on Rails core team, and lead developer of the Merb project. He is a member of the jQuery Core Team, and a core contributor to DataMapper. He contributes to many open source projects, like Rubinius and Johnson, and works on some he created himself, like Thor.

spacer

Everyone Who Tried to Convince Me to use Vim was Wrong

July 29th, 2010

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.

This entry was posted on Thursday, July 29th, 2010 at 1:27 am and is filed under TextMate. You can follow any responses to this entry through the RSS 2.0 feed. You can skip to the end and leave a response. Pinging is currently not allowed.

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

« Older Comments
spacer

Ala'a, Posted November 28, 2011, 1:26 am

Good idea to leave it while taking your first baby steps in Vim.

You can achieve that with (rather than starting vim and hitting ‘i’):

set im
or
set insertmode

C-L to leave insert mode and C-o to execute a command

spacer

drj, Posted December 12, 2011, 2:50 pm

When learning vim, the best thing one could do is print out a vim cheatsheet, and keep in handy every time vim is open. Find a cheat sheet with all the basic commands… once you get most of those down, go find a cheatsheet that has more advanced commands, or commands that you havent yet committed to memory, and continue on in that fashion, till you achieve vim ninja status.

Also download other peoples vimrc’s… many coders put them on github these days.

Keep a browser window open too, to stackoverflow…. lots of great vim tips there.

spacer

Mark S, Posted December 15, 2011, 4:36 pm

i’ve been using emacs for over 25 years, so the comments about muscle memory are important: the keybindings might be weird (though you can change them if you’d like) but they work for me. in fact, i don’t really think about them anymore…i just edit. i’m sure the same is true for vim experts.

i really, really doubt i’d become more “efficient” if i switched to vim. or anything else, for that matter.

spacer

Chris Jones, Posted December 20, 2011, 10:05 pm

@drj: Cheat sheets is the worst possible way to learn Vim. It’s a bit like folks who try to learn a foreign language with flash cards. Ten years later, they know all the stuff on their flash cards alright, but they still can’t speak the language. Learning an editor is all about committing short sequences of commands to muscle memory in order to perform editing tasks (deleting a word, reordering sentences, cutting and pasting, etc.) QUICKLY and EFFICIENTLY, without having to THINK about it.. so you can focus on what you’re coding, writing… etc.

spacer

Cody Johnston, Posted January 4, 2012, 8:54 pm

@Chris Jones: I’m sorry to be the guy that has to do this, but you need to take a step back and realize that you sound like one of the “vim masters” from the article. I was once feeling the EXACT pains Yehuda described (probably the same ones drj once felt too), and you are pretty wrong about your statement. The fact is, when you’re learning something new, you have to use whatever works for you, and cheat sheets, despite your bible-thump, can be instrumental in learning a new tool like VIM. You can’t “QUICKLY and EFFICIENTLY” learn a new thing if don’t have mental sight of how to accomplish your goal. One does not simply commit everything to memory at first glance, sir. I had this set to my background the whole time I was learning VIM and it turned out great: www.viemu.com/vi-vim-cheat-sheet.gif

spacer

Justin O'Brien, Posted January 25, 2012, 2:36 pm

I recently started using Vim but I am being drawn towards Sublime Text 2 which has support for a lot of Vim’s awesome commands. You can check it out here: www.sublimetext.com/2

spacer

Ian, Posted January 28, 2012, 9:32 am

Thanks for this! I’m around a lot of *nix admins / hackers who are convinced that vim is the One Twue Way to edit anything. They say the same things you said in your article: Don’t use the mouse! Turn off the arrow keys! No cheat sheets! Install it in Firefox! And then I have the same problem of vim having too steep of a learning curve to be able to get anything done in the short term.

So, I’ll ignore the zealots (people who speak in absolutes like that should be held in suspicion anyway) and do it MY WAY, which might be clunky and slow, but still lets me get things done in the short term while I learn a new tool.

spacer

Eric G, Posted February 10, 2012, 4:35 pm

Index cards are another good alternative, and can aid in learning all this stuff faster. For example, when you add another plugin (more screams from the Vim purists) you can bring on board a whole new set of commands and shortcuts to learn. Or say you just now need to learn about buffers. Make index cards, and use them until you don’t need them anymore.

When you’re older, you’ll find your “muscle memory” shot just like the rest of your muscles, and you’ll be thankful that you still have your index cards. :D

spacer

Friedrich Gonzalez, Posted March 10, 2012, 7:05 pm

I know this is just regular Internet-forum-flame-wars… but here is a clever thoght I read once:

There are new tools and there are old tools. The new tools are great, productive but… maybe the interface will change, it will get bloated, the core developer will quit, etc. The old tools have been tested and are not likely to change by now, maybe will be here forever.

That is the number one reason to use vim or emacs and not any of the fancy new editors. Be productive, save time, learn to do a thing just once.

PD: Also there is VISUAL mode in vim that lets you use mouse the way you use it in every editor out there but with vi commands.

spacer

Crispy, Posted March 18, 2012, 5:00 am

I learned VIM the “hard” / “true” way and was extremely excited about it. But some of my colleagues just installed MacVim and the janus plugin set: https://github.com/carlhuda/janus – and were instantly happy with that. They say it feels like “drop-in replacement” with much potential for improvement.

spacer

Buck, Posted April 13, 2012, 9:00 pm

Hey I read about your tribulations with vim, and I have to recommend my own .vimrc file to you: https://github.com/bukzor/buck_dotfiles/blob/master/.vimrc

I’ve been working on it for ~6 years now. It’s meant to be very basic, only trying to fix little misfeatures and annoyances in vim. It’s long, but that’s because it’s well commented. It’s roughly arranged by order of importance or quality-of-life improvement, so if something seems too weird, just delete from there down :)

spacer

Alexey, Posted June 29, 2012, 4:24 am

I also think that the advice to learn Vim by forcing yourself from the first day to use its commands instead of familiar system-wide MacVim shortcuts and mouse operations seems extreme.

If i were to recommend Vim to a friend, i would tell not to try to be productive with it for a few months, and view it as a game: find the minimal number of keystrokes to accomplish an editing task.

In my opinion, Vim turns editing text into playing Tetris.

spacer

Nelson Branco, Posted July 10, 2012, 5:22 pm

Nice article. I have been working with (m)Vim for a few months now and it’s a completly worthy effort.
It takes a while to custumize it and learn it (+with all the nice plugins also to learn) , as well as choosing the ideal colorscheme (and font) and also the .vimrc file… and so on.
Sometimes i still use the arrow keys (so what?) but every day i learn a new ‘trick’ and that makes me happy…
I use commandT and NERTree but the one i am aware that i am missing (of this kind) is this one https://peepcode.com/system/uploads/2012/play-by-play-wycats-i-code.png .
I am a RoR beginner and i admit that the RoR file directory is harder to get then all the ruby language and rails (even including procs, lamdas and closures… ;) )
So if anyone knows which plugin (above link) is please tell me!…
By the way, because is vim and rails related:
For the RoR begginners like me, here are 2 small tips :
Run irb from vim with !irb
Or run irb in vim from inside irb with mvim or vi vimcasts.org/episodes/running-vim-within-irb/
Happy (vim) (rails) coding!

spacer

JRodman, Posted July 19, 2012, 4:43 am

Hmm, I’ve generally suggested to people to run ‘vimtutor’ until bored, and then use as a basic editor and pick stuff up along the way.

Would this have put you off? I mean, vimtutor.

I guess I assumed that was how i learned vi (before vim) and that it would work for others.

spacer

dphrei, Posted July 30, 2012, 9:53 am

Agreed. l33tism must die for humanity to survive.

I learn vim by small, specific edits. I follow Bram Moolenaar’s advice to recognise and try-out efficient methods and to reinforce the ones I need. I expect this process to take a year or two and that’s fine. the thrill of Vim_Powa™ keeps me keen.

spacer

ADMK, Posted August 3, 2012, 2:58 pm

This post challenged me to give vim another shot, and this time it stuck—I’ve been in love with vim for months now. Some thoughts for fellow newbies:

(1) As has been said, building a good .vimrc in the beginning is crucial to make vim do by default things you’re used to in your old editing environment. Some of the commands I’ve found most useful to that end there are set number (line numbering), set hidden (work with multiple unwritten buffers), syntax on (highlighting), set ignorecase (default case-insensitive searches), set hlsearch (highlights search results), set wrap (line wrapping), set mouse=a (so you can use the mouse if necessary—not a good habit, but definitely a timesaver in certain situations), and set whichwrap=[options] (keys/commands that traverse line wraps). Also in your .vimrc, remap some of the keystrokes with unintuitive results. For me, the main ones are “nnoremap j gj” “nnoremap k gk” “noremap gj j” and “noremap gk k” to give j and k more typical row-traversing rather than line-traversing behavior.

(2) One customization has to do with the only time I was ever frustrated with vim. To avoid scrolling with the mouse, I use ctrl-u and ctrl-d all the time to scroll up/down by half-page. The problem is, in insert mode, Ctrl-u by default undoes all typing on your current line—i.e., DELETES your current line—in a way that is not recoverable by an undo. While the text in theory can be recoverable immediately thereafter (vim.wikia.com/wiki/Recover_from_accidental_Ctrl-U) if you’re lucky enough to realize what’s happened, it’s still very frustrating (and when it happened to me, I didn’t understand the situation enough to recover my text. So I use “imap ”

(3) In terms of restoring productivity lost during the switch, make sure you understand text objects and how to use the *i*nner/*a* block commands to quickly perform actions on them. Also start using t/T and f/F. This stuff alone more than makes up for almost any other “costs” of switching to vim.

spacer

ADMK, Posted August 3, 2012, 4:55 pm

Apologies for the dropped text—what was I thinking using angle brackets? To avoid the consequences of ctrl-u in insert mode, my .vimrc has “imap [C-u] [Esc][C-u]” (with [] replaced with angle brackets, of course, and for both u/c and l/c u).

spacer

martin, Posted October 5, 2012, 1:40 am

Vim!? Who can even think about using ‘that’ when Emacs is around!? (specially version 24.2.1 which rocks)

spacer

jkneb, Posted October 10, 2012, 5:42 pm

Fun how I’m experiencing exactly the same these days :) It’s about maybe the 4th time I try to switch to Vim in two years but this time I gave MacVim a try and guess what ? It’s not as painful as before AND I FINALLY gain efficiency (slowly but surely).

Cheers!

spacer

Emil, Posted October 15, 2012, 4:38 pm

@ADMK; do you have some good short introductions to the i(inner)/a(round) stuff, as well as f/F t/T commands? I have seen hints and bits but a short intro on what it’s about and why it’s cool could probably do a lot to help met started using it.

spacer

will, Posted October 17, 2012, 12:43 pm

@emil

f/F t/T commands are for jumping to the next (lower case) or previous (uppercase) occurrence of whatever character you hit next. f/F goes directly to the character while t/T goes to just before the character.

Handy for jumping around but much handier when used with other commands. For instance “cfu” will wipe out everything between the cursor and the next u, leaving you in insert mode (change find u). ctu will do almost the same but instead changes everything up to the u, leaving it there. A common use for developers would be ct) meaning ‘change everything from here to just before the closing paren. Uppercase versions do the same, just backwards from the cursor.

Speaking of parens, that’s a great use for ‘i’ or inner. Put your cursor inside of a function declaration like foo(){cursor here}. now, hit ‘ci{‘ and vim will wipe out everything *inside* the {} and leave you typing. yi{ to yank it. di{ to delete it. gUi{ to make it all uppercase… I’m using { here but it will work with most anything like ” or ‘ or ( or [ or whatevs. One that I missed for a while was t. in this context, t is tag. so cit inside of an html block while change the contents of the tag. cat will change the tag and it’s contents.

Should get you going. There are much better explanations of this stuff on the internets. :)

spacer

Ernie, Posted December 24, 2012, 7:08 am

I had virtually the same experience as you, though my starting and ending points were different. I’m an old mainframer and my experience was to get it right on the punch cards and make sure the greenbar reads the way you like and then the clunky old line-editors won’t mistreat you too much. But some of my buddies were quickly moving up to full screen (which seemed to highlight the follies of many of their global-search-replace’s).

Somehow some VAX users had worked their way into my social circles, and they just couldn’t figure out why we didn’t use vi. I had much the same experience as you did initially, and I had to wonder whether converting us to vi wasn’t a way to show off and make us look foolish at the same time.

There could be a “vi turning point story” chronicle with the number of ways one discovers productivity with Vi/M. Many years later I decided to give it another chance since our limited resource was overloaded and vi was ‘light.’ It was meant to be a temporary solution, just until we got all the boxes online that we were promised in the first place.

But a funny thing happened: I decided to find out how people adjust to vi. I read a criticism from an Emacs user who said, “Just be prepared to be hitting escape for most of your life.” I sat down at my keyboard and smacked escape with my left pinkie a few times and I decided that I could live with that.

Enter Bram Moolenaar: After I started my escape-punching life and we had machines that were up to application level rather than minimal system loads, somebody said, “Why don’t you just use ViM?” What’s that? I asked: “It’s Improved vi — vi only better.” Now I do get a little frustrated when I have to go back to old vi because my once-cryptic keystrokes have now become automatic.

But getting used to switching between modes (hitting escape all my life) was what made the real difference for me.

spacer

MBF, Posted January 7, 2013, 6:52 pm

The issue with incrementally learning vim is that it is a completely different way of editing text. It isn’t simply notepad with a bunch of shortcuts.

Now you can use it like that by staying in insert mode (which is what you did), but you are not actually learning vim. The entire purpose of vim is that it has an edit mode and an insert mode. This isn’t some purist, elitist viewpoint at all. That would be like saying someone who insists on driving an automobile instead of pushing it is a “purist”.
At some point, you will have to make the jump and stay in edit mode (by hitting ESC) until you have to actually INSERT text.

spacer

Nick, Posted January 16, 2013, 8:16 pm

I’ve been using Vim for years, and I still use the mouse and arrow keys. Not because I couldn’t switch to using HJKL, but because a) why should I? b) it makes it much easier to switch back to another editor if I have to, and I still get all the productivity boosts of everything else Vim has to offer, like all the shortcuts, regexes, and everything else. I challenge anyone to work their way around code faster with HJKL than I can with arrow keys and/or mouse.

Leave a Reply

Click here to cancel reply.

Ads from Ruby Row

Archives

  • December 2012
  • September 2012
  • August 2012
  • June 2012
  • April 2012
  • January 2012
  • December 2011
  • November 2011
  • September 2011
  • August 2011

Categories

  • Bundler (2)
  • Conferences (9)
  • DataMapper (1)
  • Engine Yard (2)
  • Food (1)
  • JavaScript (9)
  • jQuery (15)
  • Merb (26)
  • Other (80)
  • Personal (4)
  • Publications (1)
  • Rails 3 (18)
  • Rubinius (3)
  • Ruby (52)
  • Ruby 2.0 (1)
  • Ruby on Rails (39)
  • SproutCore (1)
  • TextMate (7)
  • Tokaido (1)
  • Meta

    • Log in
    • Valid XHTML
    • XFN
    • WordPress
    Core Team,
    Ruby on Rails
    Core Team,
    jQuery
    Co-Founder,
    Tilde
    Designed in California
    by New Leaders
    gipoco.com is neither affiliated with the authors of this page nor responsible for its contents. This is a safe-cache copy of the original web site.