Given the following
- I want to write a file
- Change to the directory of the file
- Execute a bash command
- change to the previous directory
I made the following command
command Asc execute ":w | :cd %:p:h | !ansible-playbook --syntax-check % "
This seems to be working so far. However changing back to the previous directory with
:cd - does not seem to work.
command Asc execute ":w | :cd %:p:h | !ansible-playbook --syntax-check % | :cd -"
My guess is, that the pipe and the stuff followed is interpreted by bash and not by vim.
How to overcome this problem? Or is there no way at all?
P.S.: I am aware of the autochdir option of vim