4 ms·
Just went searching on the internet for a vim demo video and found this: http://www.youtube.com/watch?v=QNAXa0W4OFg http://www.youtube.com/watch?v=QNAXa0W4OFg
by jason_tko 16y ago
Just went searching on the internet for a vim demo video and found this:
http://www.youtube.com/watch?v=QNAXa0W4OFg http://www.youtube.com/watch?v=QNAXa0W4OFg
Also, if you have a Mac (or most versions of Linux) you can also access an instant tutorial by typing "vimtutor" at the terminal.
- unoti 16y agoFor those of you looking at this video to get an idea of the power of vim in the hands of a serious user: although this person is using it quickly, he is nowhere near a master. The key to vi is that any time a user is pressing the same key multiple times, there is a faster way. In this video I often see the user using the same keystroke multiple times to get from here to there. Most notable, he routinely does this to get from his cursor position over to a spot later in the line (such as when changing the word "test" which was in quotes), or to get to the end of a section (such as when he was copying then changing the body of a function). If you're a vi user or an aspiring vi user that wants to get faster, then start consciously looking for times that you're pressing the same key more than about twice. Each of those times is almost certainly an opportunity to get faster. So in particular from watching the above video, these are two shortcuts that I use all the time that the video maker did not use. Let's say you have a line of text like: Img.save('roberto.png') and you want to change it to x.png. If your cursor is at the start of the line, you would never arrow over there. You would type fr (find r, which would move your cursor to the r in Roberto). Then you would type "ct.x" which means change until we get to the period and replace it with the letter x. It sounds complex, but after a while you just do it without thinking, and it's faster to type 5 keystrokes with 2 hands than a bunch of repeated keystrokes with one hand. Similarly, the } and { keys should be used to navigate to the next or previous blank line, which could have been used in this video to change the body of those functions in a couple of keystrokes instead of the arrowing around and highlighting we were seeing. I'm not trying to pick apart the video, the person is clearly fast and effective. The point is just that vi gives you the flexibility to always get faster if that's what you're into.
- eggoa 16y agoWe can shave another keystroke off your example. Instead of "ct.x", "cwx".
- unoti 16y agoBrilliant, exactly. Another important point here: A big benefit of doing changes like this is that vi has the special command "." which repeats the last change. With a single keystroke, it makes the same change you did last. In practice this comes in handy quite often. Let's say that I have a program which generates a bunch of images. Let's say it's generating 4 images, and 2 of them are thumbnails and 2 are big versions. img1.save('x-th.png',100) img1.save('x.png') img2.save('y-th.png',100) img2.save('y.png') I want to change the thumbnails to .gif. I can't just use search and replace, because I only want to change 2 instances. (Technically I could with a regex, but forget about that for a moment.) I go to the first one I watch to change, use 'cwgif' which changes the png to gif. Then I navigate to the next one, and just press period. The period key is one of the monster productivity boosts you can get from vi.
- deleted 16y ago[deleted]