Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Lord, that's so useful.

I normally include a move to next line part in my macro and then guess at how many times to run it (20@q, repeat until I get it right). It's actually the main reason I often don't bother using macros.

This is such a great tip. Thanks!



You can combine regexes with macros if you only wish to run your macro on a particular set of lines:

    :'<,'>g/foobar/norm @q
will run the macro only on the subset of selected lines that match the regex "foobar". :g/.../ will match the regex against all lines in the file.


I love the g command. Very useful to quickly cull out lines of stuff that you don't want in your file. g/foobar/d


@@ applies the previously applied macro, so after applying the macro (including the move to next line, but see below too) you can you just hold down @ and quickly go through as many lines as you need. If you overshoot, you can just press u a few times.

Another tip: when you forget to add the move to next line to your macro, you don't have to start over. You can append to a macro, just use the upper-case register name instead. So to append a down and move to beginning of line to macro 'a', you'd type qAj0


Both useful tips. I knew the macro is really just replaying whatever is in the register but it's good to connect the append dots to the equation.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: