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!"
16 comments
[ 5.1 ms ] story [ 26.7 ms ] threadThen you will be ready for emacs.
WTF? What is it, an emacs for low self esteem people? "Hey I am not smart enough to take on emacs directly, let me try something which is named like it came out of the mouth of a six year old."
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.
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.
The question is: what features did you find that decided it was worth it to switch? If not for the feature itself, then how does the paradigm of its usage help you?
For example, ci{ is often cited by developers is awesome. It's so much faster than highlighting text within curly braces and changing it so while it's a pretty simple thing, Vim's implementation makes it a breeze to use.
:%s/oldWord/newWord/g
Since then I haven't looked back.
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.
You have no idea how painful it is, having to use the mouse while editing text.
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