Maciej Kravchyk
Maciej Kravchyk

Reputation: 16727

Vim autocommand on write - pass full file path

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> 

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

Upvotes: 8

Views: 1293

Answers (1)

Maciej Kravchyk
Maciej Kravchyk

Reputation: 16727

I found it:

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

The %:p does it

Upvotes: 11

Related Questions