简体   繁体   中英

how to apply macro on list of lines with vim

let's suppose I want to apply a macro stored on register 1 on lines: 2, 5, 9 but without applying on lines in between. I saw that you can give a range but that is not what I want. I've tried some variation on :2, 5, 9 @1 without success

If those lines have something in common, you can use the :global and :normal commands:

:g/foo/norm! @1

which is slightly "smarter" but probably a bit less intuitive than:

2G@1
5G@1
9G@1

See :help :global and :help :normal .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM