Ask HN: Use Vim? What Feature "sold"you?

There's been a lot of buzz lately about Vim and with projects like Janus, getting started has never really been easier. However, when a newcomer does research on how to get going with Vim, there's a ton of duplicate information, but not a lot (at least that I've found) on what features really finally convinced users to deal with the learning curve and really dig into Vim. I find it hard to believe that using h j k l to navigate is really Vim's strong selling point and yet it's what we hear about most often.

The only consistent answer I've heard is that ci is a lifesaver. While that's true, I'd also be interested in hearing about what tools and tricks you've picked up that made you say, "Ok, Vim is my editor!"

  • After some practice with Vim I started to think about editing in terms of Vim's commands. That made me very effective. And it's not only about h j k l. It gives you many small tools that you can combine. The basics are actions and movements. Let me give you a few basic examples.

    Some movements are:

    - h, j, k, l,

    - f <char> - the given character,

    - w / b - beginning of the next / previous word,

    - 0 / $ - beginning / end of the line.

    Some actions:

    - d - delete

    - dd - delete whole line

    - y - yank (copy to the Vim's clipboard)

    - p - paste

    - c - change

    - <n> G - go to the n-th line.

    Their combinations could be:

    - d f . - delete from the cursor to the first period

    - d w - delete the current word

    - c w - change the current word

    - d 0 - delete to the beginning of the current line

    - dd 10 G p - delete the current line (that also puts it in the Vim's clipboard), move to the 10th line and paste the deleted one there.

    Of course it gives you much more: searching, replacing, scripting, plug-ins, syntax highlight, auto-completion, browsing etc.

  • I use to wonder the same thing myself before I started using Vim.

    Now I'm not a Vim expert but if I had to sum up the benefits, I would say that it allows you to keep your hands on the keyboard _and_ your fingers on the home row the entire time when programming. It's a subtle usability benefit that means that I can use more of my cognitive resources on the programming logic when I don't have to take my eyes off the screen to find the mouse, reach for the mouse, bring my eyes back to the screen, use the mouse and place my hands back on the keyboard. This is a bigger distraction than it sounds.

    I know most editors have keyboard shortcuts but for me the user experience is just not the same as Vim's and I didn't fully appreciate this until I was reasonably proficient at using it.

    Edit: formatting

  • My answer is probably not the best answer here but a friend uses Vim and I was introduced that way. I'm sure if I didn't know anyone using Vim, the chances of me picking it up and trying to dive head first on my own into how Vim works would be slim, albeit not impossible.

  • I don't know that this answer is in the spirit of the question you're asking, but I think anyone who does software development for a living needs to know at least the basics of vi(m).

    If it hasn't happened yet, some day you're going to find yourself logged in to an unfamiliar Unix-y system's console and need to edit some files. You may not be able to start X and get to your favorite GUI editor. Emacs may not be installed and you may not have the authority or time to get it installed. (Side question: Do any Linux distros install Emacs out of the box?) But vi(m)? Yes, it will almost certainly be installed, and you're going to want to know how to use it then.

  • First off I am a VIM noob. What makes me say I want to edit a file in VIM rather than something else? It would have to be the search, modify, save routine. As an example: opening an ini to change a specific value, so much easier and faster in VIM than any other editor I have tried. Another is the ability to use cut, copy, paste with multiple registers.

  • I use Vi because it decreases the learning curve for new languages. No new IDE; no new set of emacs key-chords and mode-tricks. I can edit very efficiently in Vi, and all of my editing tricks/habbits apply to all languages.

    Technically I use Vim, but a lot of Vim features violate my "no language specific features" rule. So I usually restrict myself to Vi features.

  • My favorite feature is that it's around $60 dollars cheaper than Textmate.

  • I've been using Vim for a long time, maybe since version 3 or 4, because what sold me was multiple windows, either into the same file, or each window displaying different files.

  • I don't use vim, I use fuv - http://secretgeek.net/fuv_intro.asp

  • I can edit without using the mouse.

    You have no idea how painful it is, having to use the mouse while editing text.

  • The first real command I learned was how to find and replace in a file:

    :%s/oldWord/newWord/g

    Since then I haven't looked back.