Asenar Asenar - 5 months ago 6
Bash Question

excuting vim command silently then echo in vim

I want to execute a shell command on

autocmd BufWrite
in my
, then echo (in vim) a message saying it's donem without showing the shell.

touch *.less
), then echo an information message saying "file touched !".

The first part works, but the 2nd command is executed in the shell instead of vim.

The command should be something like this:

autocmd BufWritePost *.less silent! !touch '%:p:h'/*.less | echo 'file '.expand('%:p:h').' touched !'

I think I need a way to "ends" the command and allow an other command.

I tried this without more success:

:silent !touch '%:p:h'/*.less && exit 0 | unsilent! | echo "file touched"

Any idea ?


It should work if you past by a function :

function! Cmd()
    silent! execute '! touch %:p:h/*.less'
    echo 'file '.expand('%:p:h').' touched !'

autocmd BufWritePost *.less call Cmd()