/dev/blog
Bez Hermoso, Software Engineer @ Block
:r <path/to/file> when executed will read the contents of a file and insert it to where the cursor is in the file being edited. But just like the :w command, you can read the output of a command instead. Just prefix the comamnd with !.
Here is a quick example:
:r !echo 'SELECT name, email FROM users ORDER BY created_at DESC LIMIT 10;' | mysql -u root -p app_db
This will insert the result of the query into the file.
See
:help :readfor more details.