Running Shell Commands with :!

Run anything

:!command hands the command to your shell and shows the output, then waits for you to press Enter before returning to the buffer.

:!ls -la
:!git status
:!python3 script.py

% means the file you are editing

Inside a :! command, % expands to the current file’s path. This is the piece that makes the bang genuinely useful:

:!python3 %          " run the file you are looking at
:!node %
:!chmod +x %

Repeat with :!!

:!! re-runs the last shell command. Edit, :!!, read the result, edit again — a tight loop without ever leaving the editor.

Where it fits

Use :! for one-off jobs: run a script, check git status, make a directory. When you want the output as text you can edit, see reading output in.