2

I'm trying to deploy some static content upon writeing 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()
2
  • 3
    Your autocmd depends on vim being in the directory holding myProject; there are several options that could affect that. What does :echo g:netrw_keepdir show and what does :echo &acd show, for example. After navigating, what does :echo getcwd() show?
    – user21497
    Commented Feb 8, 2016 at 21:44
  • 1
    @user21497 ah, thanks, your comment helped me realize the issue. I needed to use */myProject/frontEnd/** as my path. If you convert your comment to an answer I'll mark it as accepted. Commented Feb 9, 2016 at 0:13

1 Answer 1

3

Your autocmd depends on vim being in the directory holding myProject; there are several options that could affect that. What does :echo g:netrw_keepdir show and what does :echo &acd show, for example. After navigating, what does :echo getcwd() show?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.