Live data from Hacker News

Two Simple Steps Helped Me Learn Vim

adamdelong.com

41–50 of 92 posts

Re: Two Simple Steps Helped Me Learn Vim

#41
post #24

A more elegant solution than a notecard may be using a vim cheatsheet wallpaper, like this: http://vimfoo.com/2012/09/vim-shortcut-wallpaper/ The downside of that is that it isn't customizable, so I get why he likes the 3x5 card. But at least you can't lose this.

Notably that only features the movement commands. But by limiting the scope it allows for a remarkably intuitive layout that helps put everything in context.

Thanks for the link!

Re: Two Simple Steps Helped Me Learn Vim

#42
The most important thing I would say to anybody that wants to use vim is relax! Here are some steps I think will be helpful:

1 ) Install vim with janus and use gvim/macvim. This will allow you to use vim pretty close to your previous editor.

2) Learn hjkl movement and how to move between insert/movement/visual modes.

3) Try to use them as much as possible. It's ok if you use arrow keys or mouse from time to time.

4) Introduce no more than one additional feature a week.

5) Have fun! There is no "right way" to use vim. Use it how you see fit.

Re: Two Simple Steps Helped Me Learn Vim

#43

Here are some more tips: - disable arrow keys - turn relative numbers on by default - force yourself to only move vertically using relative numbers - force yourself to only move horizontally using [fF,;]

I think disabling the arrow keys is a mistake for someone just coming to vim. The arrow keys can act as a warm blanket of familiarity while learning the harsh winter of vim. When a noob is making mistakes and getting frustrated having the arrow keys work like normal is a comforting reprieve.

Once someone has a couple of months of vim under their belt then would I recommend disabling the arrow keys.

Re: Two Simple Steps Helped Me Learn Vim

#44
post #22

I've always wanted to learn vim, as so many great coders use it and swear by it, and it doesn't seem fundamentally harder than any other power-user skill. My biggest fear is that I work with novices (who are using something like Sublime) on a regular basis, and it's more friction than it's worth to switch between the two kinds of muscle memories. Also...maybe I don't write/edit enough code to justify learning vim? I…

I agree that an advanced developer spends very little time actually typing, and I think knowing some of the more advanced vim commands can help cement that. Visual block mode and command-limited search and replace in particular are vital features for a software developer, when so many of the code changes that need to be made are similar in multiple locations.

Re: Two Simple Steps Helped Me Learn Vim

#45

Time and again, these "how to coerce yourself into learning this hostile tool called vim" posts appear. I read them, and it sparks my interest. But usually, whats missing is part 2, which goes: "... and this is why it was so totally worth it". An no, just because it works over SSH and is installed on every server is not quite sufficient. Also, are you programming in a script language or a .NET or JVM behemoth?

"... and this is why it was so totally worth it".

This is something that is difficult to explain, but absolutely clear to you once you have achieved some degree of efficiency.

Muscle memory makes the editor disappear and let you focus, not on the keyboard, not on the menus, but on code itself.

I suggest you watch some live-coding videos of people very experienced in the editor to get an idea (in this case the programmer uses emacs, but the concept is the same):

https://www.youtube.com/user/handmadeheroarchive

Re: Two Simple Steps Helped Me Learn Vim

#46

Time and again, these "how to coerce yourself into learning this hostile tool called vim" posts appear. I read them, and it sparks my interest. But usually, whats missing is part 2, which goes: "... and this is why it was so totally worth it". An no, just because it works over SSH and is installed on every server is not quite sufficient. Also, are you programming in a script language or a .NET or JVM behemoth?

I first saw Vim in use back in 2000. I was working at NuMega (Compuware lab at the time) and I was a Windows only user that was just starting to get very comfortable with the DOS prompt and I used Notepad for any editing that wasn't done in Visual Studio.

I had some huge file in which I had to do a bunch of refactoring. Some search and replace, and some reorganization.

I had been plodding away, copying, pasting, and repetitively hitting the arrow keys and typing a few characters in each place for about 5 minutes when a friend came over and saw what I was doing. He was an absolute *nix expert. After a few moments, he told me that he could finish all those changes in just a minute. I had seen him code in Vim before, and was impressed, but it seemed like magic at the time. I saved the file and went over to his desk and asked him to walk me through exactly what he was going to do. He loaded the file up in Vim and started with a quick regex that knocked out 80% of the work. He then recorded a macro that yanked the current counter number into a buffer, searched for the next edit position, pasted in the counter number, incremented it, then shifted position to the next code block and updated that reference as well. He then asked me about how many sections there were. I said about a hundred, so he typed 99@q and poof! There were a few more, so he did a :g//p to see how many lines there were and then did that many more macro invocations and the file was done.

I was hooked at that point. He set me up with gVim and some tutorials and taught me the most basic fundamentals and told me that it didn't matter if I couldn't make vimgolf par for the first year or so. If I used it and every once in a while picked up a new motion or command, after a few years, it would change my coding life.

He was right.

Re: Two Simple Steps Helped Me Learn Vim

#47

Time and again, these "how to coerce yourself into learning this hostile tool called vim" posts appear. I read them, and it sparks my interest. But usually, whats missing is part 2, which goes: "... and this is why it was so totally worth it". An no, just because it works over SSH and is installed on every server is not quite sufficient. Also, are you programming in a script language or a .NET or JVM behemoth?

I think that it is necessary to learn Vim not because it is the best text editor (it's not!), but because it is one of the best ways to edit texts.

It was hard for me to get used to it (I forced myself to write all scripts - Perl, Bash etc. - in Vim). But it was absolutely worth it. Now I use vim mode in browser, in huge Java IDE (Idea), in file manager etc.

Vim (as an editor) has many disadvantages (Google it). But it is a superior way to edit texts. I switched to Emacs recently (for LISP-coding), but immediately downloaded Evil package. Now I have best from both worlds :)

Yes, I use Emacs, but my love is Vim.

My point is: all text editors are just tools. But try to learn Vim way to edit texts.

Re: Two Simple Steps Helped Me Learn Vim

#48

Time and again, these "how to coerce yourself into learning this hostile tool called vim" posts appear. I read them, and it sparks my interest. But usually, whats missing is part 2, which goes: "... and this is why it was so totally worth it". An no, just because it works over SSH and is installed on every server is not quite sufficient. Also, are you programming in a script language or a .NET or JVM behemoth?

I think a great answer to this question is in this stack overflow answer: http://stackoverflow.com/questions/1218390/what-is-your-most...

To answer you second question: yes. I've done quick scripts and giant programs in vim. Also note: I use full IDEs in conjunction with vim where appropriate - I mean, why wouldn't I take advantage of Visual Studio when doing C#, but even then I still regularly drop into Vim (because of the stuff in the above link).

Re: Two Simple Steps Helped Me Learn Vim

#49
post #22

I've always wanted to learn vim, as so many great coders use it and swear by it, and it doesn't seem fundamentally harder than any other power-user skill. My biggest fear is that I work with novices (who are using something like Sublime) on a regular basis, and it's more friction than it's worth to switch between the two kinds of muscle memories. Also...maybe I don't write/edit enough code to justify learning vim? I…

If you have tools that work for you I don't see a reason to change. I use vim because it's a great editor, can run in a terminal, and is open source. I know the producer won't go out of business.

Ah yes...the ability to use in a terminal is a huge thing. That ubiquity was not important to me a year ago, but now I'm at a Unix shell so often that I most definitely feel the pain of doing quickie scripting via nano/pico. Hmm, I think you've convinced me :)

Re: Two Simple Steps Helped Me Learn Vim

#50

Time and again, these "how to coerce yourself into learning this hostile tool called vim" posts appear. I read them, and it sparks my interest. But usually, whats missing is part 2, which goes: "... and this is why it was so totally worth it". An no, just because it works over SSH and is installed on every server is not quite sufficient. Also, are you programming in a script language or a .NET or JVM behemoth?

For me, I was always annoyed with how tedious it was to edit things. i.e, The gap between what I think vs what I have to do in the editor to get it done. This constant annoyance was what drove me to spend time and energy into learning it. I believe that if you don't care about it, you won't really benefit out of it. Because the whole point of switching to Vim/Emacs is to minimise the gap between what you think and how you do it.

Let me give you an example. You'll be thinking, "I need to change all the arguments to a function." In other editors, you'll press the arrow keys until you get to one end, press backspace key multiple times until you get to the other end. In Vim, I'd do "ci(" which means "change everything inside (" - which is pretty much how I think about what I need to do. A similar but more common example is changing text inside quotes. Again, that'd be 'ci"'.

Not everyone feels the annoyance about this and if you don'tt, hats totally fine. Learning something just because its cool is never worth it. Learn it if you really care about it.

Also read this post by Yehuda Katz about how he started for some ideas. http://yehudakatz.com/2010/07/29/everyone-who-tried-to-convi...

Post reply on HN