Live data from Hacker News

Two Simple Steps Helped Me Learn Vim

adamdelong.com

81–90 of 92 posts

Re: Two Simple Steps Helped Me Learn Vim

#81
What made the difference for me was a Vim version with a project/file drawler, like the one by alloy: https://github.com/alloy/macvim

After a while I got fluent enough with vim to switch to NERDTree.

Btw, such a shame vimR (http://vimr.org/) wasn't around back when I started using vim, it looks awesome to learn vim-motions but still be able sometimes to use insert-mode and mouse if you have to get something done quickly.

Re: Two Simple Steps Helped Me Learn Vim

#82

Earlier quoted context omitted.

Would you be willing to share the HTML for your wiki page? Just looking at the table of contents, it seems really useful for those of us trying to learn vim compared to the normal cheat sheet that looks like a periodic table...

Sure! Here it is: http://pastebin.com/BbJv6sWX It's raw HTML, sorry for the format :) Note that I have the same kind of stuff for everything linux related: http://imgur.com/fI12YY5

Great, thanks!

Re: Two Simple Steps Helped Me Learn Vim

#83

Earlier quoted context omitted.

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 ho…

Your example falls flat. Any text editor with regular expression support can do that... Do you have another example?

I think you are missing the elegance. The example isn't change foo to bar in f1(foo); f2(foo); f3(foo). The example is the series of steps and physical mode changes to change f(foo) to f(bar).

To do this one must select the letters foo somehow and then cause bar to be typed in their place. This can be done a number of ways in a "normal" text editor. For example, the person might double-click foo with the mouse to select the word and then type in bar. This does four things: 1. places the cursor in the location of foo; 2. select foo; 3. remove foo; 4. insert bar. In this example, there is one or two physical input context changes: from keyboard to mouse and back or maybe just from mouse to keyboard.

In vim, the physical input context never changes. The keyboard remains your context throughout. The person would 1. Position the cursor somewhere by foo (i.e. by typing a search expression like /foo); 2. type ci( which selects everything in the parenthesis, deletes and changes the context to input; 3. type bar (and probably 4. press the key).

I suspect that some people aren't bugged very much by the physical context switch and so the point of this is lost. Other people are bugged by it and struggle along until they find vi, emacs or the like.

Re: Two Simple Steps Helped Me Learn Vim

#84

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,;]

Why would you want to disable arrow keys?

I would argue that it's best to disable arrow keys in insert mode only. This is the real problem here. By using arrow keys in insert mode, the novice ends up using vim just like a glorified notepad, and never truly understanding the different modes. Since they aren't ever going back to command mode, they never consider using more advanced movement operators, and then they never realize the power of composing motions and commands.

Whenever I start teaching someone vim, I always add this to their .vimrc:

    inoremap  
    inoremap  
    inoremap  
    inoremap  
This way, arrows still work as expected in command mode, but not in insert mode. The novice will learn to only insert in insert mode, and move and operate in command mode.

Re: Two Simple Steps Helped Me Learn Vim

#85
post #17

The biggest thing that helped me to learn to use vim fluently by building up muscle memory (and making commands automatic) was playing Vim Adventures, a browser based adventure game that gradually teaches you vim commands: http://vim-adventures.com/ I haven't tried the full (paid) version yet, but the demo was enough to get me moving around text quickly. Now I finally understand why people use this crazy thing. :) Al…

The biggest thing that helped me was when I realized that it actually all makes sense. Every time you use vim and catch yourself repeating a command over and over (x, dd, hjkl) take a moment and think about if there is a more efficient way to do it by combining the commands you know. Let's say you need to delete everything from you current cursor position to the next paren in the current line, ok you know that: t ->…

Yes, but there's a difference between "makes sense" and "I can do it without thinking, so it is a lot faster than pressing ctrl + right arrow a few times" which then leads to "maybe I'll use vim instead of Sublime Text after all." :)

Re: Two Simple Steps Helped Me Learn Vim

#86
post #17

The biggest thing that helped me to learn to use vim fluently by building up muscle memory (and making commands automatic) was playing Vim Adventures, a browser based adventure game that gradually teaches you vim commands: http://vim-adventures.com/ I haven't tried the full (paid) version yet, but the demo was enough to get me moving around text quickly. Now I finally understand why people use this crazy thing. :) Al…

The biggest thing that helped me was when I realized that it actually all makes sense. Every time you use vim and catch yourself repeating a command over and over (x, dd, hjkl) take a moment and think about if there is a more efficient way to do it by combining the commands you know. Let's say you need to delete everything from you current cursor position to the next paren in the current line, ok you know that: t ->…

This is precisely why I love vim. It's like *nix. Small parts come together to make the whole a lot more better. I struggled quite a bit with vim. But once I read this stackoverflow answer, it all made sense!

http://stackoverflow.com/questions/1218390/what-is-your-most...

Re: Two Simple Steps Helped Me Learn Vim

#87
post #85

Earlier quoted context omitted.

The biggest thing that helped me was when I realized that it actually all makes sense. Every time you use vim and catch yourself repeating a command over and over (x, dd, hjkl) take a moment and think about if there is a more efficient way to do it by combining the commands you know. Let's say you need to delete everything from you current cursor position to the next paren in the current line, ok you know that: t ->…

Yes, but there's a difference between "makes sense" and "I can do it without thinking, so it is a lot faster than pressing ctrl + right arrow a few times" which then leads to "maybe I'll use vim instead of Sublime Text after all." :)

Everything takes time to master, but understanding/being able to make sense of something makes a big difference.

You just started learning vim and are moving around with hjkl and x-ing words letter by letter, then you learn about moving with w/W and b/B and repeating/combining commands (2w, 2b, ...), and the next time you're using it you think "wait a minute, d is delete, I use dd all the time, why wouldn't I just d2w to delete those 2 words, huh, it didn't work right, the cursor is in the middle of the first word, I have to bd2w", at least that's somewhat how I first started getting it. Once you understand something it's hard to forget and after a short time using it you don't really need think about it like you mentioned.

Re: Two Simple Steps Helped Me Learn Vim

#88
post #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 program…

Do you know what is the guy using within VS here? Is this an Emacs extension or something added on top. He seems to be going full screen and switching files very quickly. I've seen this before on someone's machine but didn't ask about it. I don't know anything about emacs myself.

Re: Two Simple Steps Helped Me Learn Vim

#89

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 had/have to use vim almost every day (a lot of it was managing headless servers, but also being a linux user myself), and it was somewhat of a pita every time I used it, but a bit less so than nano, pico or what have you. After some time I finally had enough and decided to invest some time in figuring it out mostly in the hope of making it a bit less of a pita. Also, so many people seemed to just love using vim. Makes you think that it may not be the most pointless thing in the world to invest some time in.

What I got from it personally is:

Most text editors now feel like there's not much to them, you rote learn the editor specific shortcuts, but they often don't have any meaning on their own so there is a tendency to forget them when they aren't used every day. Luckily the ones used most are often somewhat consistent across editors so it doesn't take much time to get to some level of proficiency with a new editor. Also you often have to use your mouse and sometimes arrow keys for efficient movement and text selection. This requires constantly moving one of your hands out of the typing position which seems a lot more distracting if you get somewhat used to "mouseless" text editing.

With vi(m), yes, you have to learn the shortcuts/commands but they kind of add together, almost every command or way to do something seems not only useful by itself but also expands your vocabulary and enables you to tell the editor what it should do in a more efficient way. In a way you are making up shortcuts on the fly all the time by composing commands you know depending on what you want to do, only most of the time (at least while editing text) you don't actually think about commands or shortcuts just like you don't have to think about ctrl+x and ctrl+v, it's just select, cut, paste.

tl;dr, my opinion

Is it worth spending the time and effort given the steep learning curve? If you don't already use vim at least some of the time and would have to force yourself into using it, I personally would say no. I think I still would have tried it but I don't know if I would have stuck with it once the novelty had worn off. I wasn't really unhappy with text editors, I just didn't like using vim the way I was using it. Also you end up adding "vim mode" plugins to every damn thing you type text into, IDE's (used for those behemoths), other text editors, web browsers, ...

Re: Two Simple Steps Helped Me Learn Vim

#90
post #35

Earlier quoted context omitted.

Vim is much more efficient. For example, within Tmux, one never needs to leave the terminal; with ST, there's a frequent switching cost which compounds over the course of a day. If one were to put Tim Pope up against an ST master, it's almost certain Pope would win.

I love the iTerm2 + tmux + vim + zsh environment. It takes a little time to figure out how to juggle the configuration for them, but once you do, it's super efficient.

I'm using the same setup (plus spf13.vim, powerline and Oh My Zsh). It looks beautiful and works very well. Here is a screenshot of my setup: http://postimg.org/image/9jqokq0ll/full/
Post reply on HN