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?
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?
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