I don't understand how to make $* to work when I set &makeprg. For example, if I set &makeprg = 'pandoc --from=markdown --output %:p:r:S.$* -- %:p:S' and I run make html, then the $* is not substituted with html. I am working with Vim 9.1071.
1 Answer
If I do:
let &makeprg = 'pandoc --from=markdown --output %:p:r:S.$* -- %:p:S' Then:
:make html generate the command:
pandoc --from=markdown --output "myfolder/myfile".html -- "myfolder/myfile" The problem is with the %:p:r:S.$* part. The the :S that escape the path for the shell is actually quoting the path moving the argument (i.e. html) outside the quote.
You get "myfolder/myfile".html where you probably like to have "myfolder/myfile.html"
I would not use the shell escape (i.e. :S) and quote the path explicitly: "%:p:r.$*".
Maybe you would like to do:
let &makeprg = 'pandoc --from=markdown --output "%:p:r.$*" -- %:p:S' that generates:
pandoc --from=markdown --output "myfolder/myfile.html" -- "myfolder/myfile" - 1I’m having a really hard time discerning what’s different in this answer from the questionD. Ben Knoble– D. Ben Knoble2025-02-15 01:06:31 +00:00Commented Feb 15 at 1:06
- I'll improve my explanations :-)2025-02-15 03:33:50 +00:00Commented Feb 15 at 3:33
- 1Interesting: with
"foo".htmlthe shell eventually sends justfoo.htmlto the external command, so I’m not sure the diagnosis of the problem is correct. But OP has indicated the solution is, so that’s very interesting indeed…D. Ben Knoble– D. Ben Knoble2025-02-15 22:08:01 +00:00Commented Feb 15 at 22:08