这里就是我想要的bash做的,首先在伪,然后在bash,据我已经得到了,那么错误:猛砸替代自动命令
“我想要什么”伪
If a file is saved in the "Cover Letters" directory with a filename ending in "md":
run a Bash command like:
pandoc [FILENAME] -o [FILENAME].replace(".md",".pdf") -s -S
我已经走到这一步,
:autocmd BufWritePost ~/Dropbox/Professional/Covers/*.md pandoc % -o ${%/md/pdf} -s -S
此代码正确识别时,被保存在“MD”的文件在Dropbox文件夹中,然后运行一个包含文件名的命令。但是,命令出错:
"test.md" 1L, 6C written
:!pandoc test.md -o ${test.md/md/pdf} -s -S
/bin/bash: ${test.md/md/pdf}: bad substitution
shell returned 1
我的替换出了什么问题?我觉得像我这么近......
编辑:当前版本:
autocmd BufWritePost ~/Dropbox/Professional/Covers/*.md #!star='~/Dropbox/Professional/Covers/'% && fin=${star/md/pdf} && p andoc star -o fin -s -S
我已经回答了类似问题[\ [here \]](http://stackoverflow.com/a/38671667/1620779)。请参阅函数中的替代部分,这正是您所需要的。 – sjsam
谢谢,是否替换只适用于变量而不是字符串?我不知道如何让Vim执行一个多行bash脚本(而不是一行代码)。 –
$ {test.md/md/pdf}有什么问题? –