I'm trying to deploy some static content upon write
ing a buffer with an autocmd:
augroup dep
autocmd!
autocmd BufWritePost myProject/frontEnd/** :call s:deploy()
augroup END
The s:deploy
function basically does the copy operation.
The frontEnd
project has a bunch of directories with subdirectories for various JavaScript, CSS, and other files I want to be deployed.
I've found that my autocmd works great when saving files after starting Vim like this:
vim myProject/frontEnd/index.html
The autocmd also works when saving files after starting Vim like this:
vim myProject/frontEnd/js/file.js
But, when the autocmd does not execute when I start out at the above index.html
and then use netrw to navigate to file.js
. It's like the navigating kills the autocmd.
Any ideas on what is happening here?
EDIT for future Googlers:
The solution I was looking for (that @user21497's answer helped me realize) was to use a pre-pending wildcard in my autocmd:
autocmd BufWritePost */myProject/frontEnd/** :call s:deploy()
*/myProject/frontEnd/**
as my path. If you convert your comment to an answer I'll mark it as accepted.