5

I want to execute some external program to format my code.

:silent execute "!eslint --fix -o /dev/null %" | redraw!

But the screen will jump to the shell output screen and shortly back to vim again. How I can avoid this short flash?

5

Since the external command is executed via the shell, you need to append an ampersand (&) to launch the process in the background:

:silent execute '!eslint --fix -o /dev/null % &' | execute ':redraw!'

You could also try the plugin vim-fixmyjs.

Then, to format on save, just add the following to your .vimrc:

au BufWritePre *.js :Fixmyjs
au BufWritePre *.jsx :Fixmyjs

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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