写入时执行Vim自动命令-传递完整文件路径 [英] Vim autocommand on write - pass full file path

查看:99
本文介绍了写入时执行Vim自动命令-传递完整文件路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

每当我在Vim中保存文件时,我都希望执行bash脚本.问题是我不知道怎么办,或者是否有可能将完整路径传递给文件,而不仅仅是传递文件名或打开的相对路径.

I want to execute a bash script whenever I save a file in Vim. The problem is I don't how can I, or if it's possible to pass the full path to the file, rather than just the file name, or relative path that was opened.

这是我正在使用的代码,它可以工作,但是只有相对路径,这对我没有用.

This is the code I'm using, it works, however only relative paths, which is useless to me.

autocmd BufWritePost * !~/.config/nvim/scripts/on_save.sh <afile> 

有什么方法可以将完整的文件路径传递给bash脚本吗?

Is there any way to pass the full file path to the bash script?

推荐答案

我找到了:

autocmd BufWritePost * !~/.config/nvim/scripts/on_save.sh %:p  

%:p 完成

这篇关于写入时执行Vim自动命令-传递完整文件路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆