4 ms·
I use Visual Slickedit, Notepad++, and Visual Studio macros frequently. I typically map them to ctrl-f11 (record/stop recording) and ctrl-f12 (playback). In all
by SomeCallMeTim 13y ago
I use Visual Slickedit, Notepad++, and Visual Studio macros frequently. I typically map them to ctrl-f11 (record/stop recording) and ctrl-f12 (playback). In all three editors, I can just record, hit keys, stop, and playback (as many times as I hit the key). Notepad++ and Slickedit both offer you the option of binding the macro to a key more permanently too.
As I mention in this other comment [1], vim and Emacs hardly have a corner on the macro market.
:norm looks powerful, yes. But when I want to do something like that, I create a regex search that matches what I want and then record a macro that includes the "search next" key. Not quite as nice, because I have to keep hitting the "play macro" key, but gets me 95% of the way there.
More complex (or numerous) transforms just become a script that I run on the file. But that's an extremely rare operation for me. For me it comes down to the fact that saving the 5 minutes to set up that script, once a year when I need something that complicated, would take a crazy long time to amortize over the three years it would take me to become that good at vim.
[1] https://news.ycombinator.com/item?id=5696927 https://news.ycombinator.com/item?id=5696927
- DennisP 13y agoI'm not arguing that other editors aren't powerful. I have less experience with others in any case. But vim does work well. A simple example I show off to coworkers: FirstName MiddleName LastName converted to: a.FirstName = b.FirstName, a.MiddleName = b.MiddleName, a.LastName = b.LastName, To do 20 iterations of that, you can hit qw, do the first with the same commands you use all day, stop recording and hit 19@w for the rest. The whole thing flows into your normal editing so easily you barely think about it. You build macros as you go for tiny little repetitive actions that aren't worth the bother to write a script for, or that you may never use again. I don't bother saving my macros, and I've barely touched vimscript. I wouldn't say it takes anywhere near three years to learn that either, more like six months. After a week or two you stop going insane, and have basic Notepad-level competence. Then you just gradually add keystrokes, and each one makes you a little more productive.
- SomeCallMeTim 13y agoI can do that pretty trivially in any of three editors as well. I just did it now in about 20 seconds, just as a proof of concept. I don't get the "repeat count" functionality that I know comes for free in vim, but at the same time, I rarely know HOW many lines I need to apply a macro to, and so just letting key-repeat take over until I'm almost done works for me. There are also times when the macro works on blocks of text, but there are occasional line breaks that would break the macro, and repeating until I get to a line break, skipping it, and then proceeding is easy. When I AM in vim and I need to, for example, delete some large number of lines, I find myself trying to guess how many lines, but guess on the small size. Then I guess again, until I get close enough to see the exact number. I probably should use "visual" mode more often for that particular task, but the point is that being able to repeat a macro an exact number of times is (for me) LESS useful than just being able to use key-repeat at 10/second until the task is done.
- Osiris 13y agoWhen I AM in vim and I need to, for example, delete some large number of lines, I find myself trying to guess how many lines, but guess on the small size. Then I guess again, until I get close enough to see the exact number. That's my biggest issue using vim, the need to count lines before every operation. I keep getting the feeling I'm doing something wrong when I do that. Sometimes I just break down and use visual selection mode to select the text and delete the whole group, much like I'd do in another editor. Is there something I'm missing about having to count before doing operations in vim?
- JulianWasTaken 13y agoUsually, yes. I never count. There's a lot of alternatives depending on what you're counting. If you're deleting a block of lines say, usually it's not just some random block, and so usually you want some more targeted motion. Like e.g. d} or d[m for an exotic example. Or d/stuff if you're lazy, like I often am. There's also `relativenumber` for when you really do need to count, but I'm ambivalent on whether I like it. And sometimes you just want `.`. It's dirty, but sometimes it's quicker. I like to basically always be typing every time I have a goal in mind. So I never want to be thinking really for too long once I've decided where I want to get. So I'll do dw... once in awhile. So yeah, it depends.