On 2020-09-02 23:23, russurquhart1 via vim_use wrote:
> Yesterday, with the groups help, I was able to apply a macro to a
> group of Markdown files in my site directory, using: :args
> ~/site/**/inde*.md :argdo :normal @b
> :argdo :write
> (@b is a macro that searches for '---', moves up two lines, and
> inserts a new line, 'beta: true') I THOUGHT this would work, but i
> found out it didn't make it through all the files.
In theory, this should do it
:set hidden
:argdo 1/---/-2put='beta: true'
(this assumes that the first "---" doesn't fall on the first line;
otherwise make sure you have 'wrapscan' set too and use '$/---/'
instead)
Depending on whether you insert the text above or below the line 2
above the "---", you might need to change that to "-3" instead of
"-2".
If you like the results,
:wall
> Are there limitations in trying to run a macro across a bunch of
> files like this? Has anyone else done this? Thanks again!
The biggest issue stems from a macro bombing out unexpectedly,
halting the process. As long as the macro doesn't trigger an error
condition, it should work fine. However, tracking down where the
macro fails causes more trouble than I find it worth, so I like to do
it with ex commands as above :-)
-tim
--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/20200902191841.662e232a%40bigbox.attlocal.net.
No comments:
Post a Comment