You execute external shell commands from within vim by prefixing with a !:

:! mvn test

This will pop you out into your shell until the command finishes.

Also, you can read the output of the command right into your current file:

:r! env

I like using it to move files around without leaving my editor, but I might start running code formatting, too.

Update: It’s also a great way to get sample command output into a blog post!


SOURCE:

https://www.linux.com/learn/vim-tips-working-external-commands