3 ms·
Damn, I've been using vim for almost a decade and didn't realize that /<term> worked as a movement so you can do things like y2/foo and yank to the second occur
by dschobel 15y ago
Damn, I've been using vim for almost a decade and didn't realize that /<term> worked as a movement so you can do things like y2/foo and yank to the second occurrence of “foo” (to use the example from the tutorial).
That's why I scan every beginner vim tutorial that comes across hn. I always learn something
- billybob 15y agoTook me years to learn that one, too. It may be favorite Vim trick now. Basically everything that can make your cursor jump can be used as a motion with a command - moving to a mark, undoing/redoing jumps with Ctrl+o and Ctrl+i, and hopping to a matching brace with % are more examples. Wrote a short intro myself about such revelations: http://nathanmlong.com/vanquish/ http://nathanmlong.com/vanquish/
- saraid216 15y agoI gave up pretending that I'm a Vim beginner a year or two ago, but I also continue to skim through and learn from "beginner" tutorials that show up in my stream. People always pick a different set of "basic" commands, and from this one, I learned about "t<letter>", which I hadn't known before.
- Ideka 15y agoFunny. I found out about that early, merely experimenting. I rarely use it nowadays tough. I used to use it for stuff like "delete up to the next dot" and the like. But that was until I learned about f and t. :)
- Estragon 15y agoSame thing works in emacs. Incremental search sets the mark at point of initiation, so you get the same effect with C-s foo C-s C-w.
- jrockway 15y agoExcept, let's be honest, Emacs' way makes a lot more sense. Someone who has used Emacs for ten minutes can easily figure this out because Emacs tries to help the user. The naive way of copying to the end of a search term is C-SPC C-s term ENT C-w. But, after you've hit ENT to end the search, Emacs does something amazing. It prints "Mark saved where search started." So now the next time you run this command, you know you won't need to set the mark. Because it told you! (Eventually, you'll learn to expect this behavior because pretty much every interactive motion command does this and prints "Mark set.")