Search This Blog

Tuesday, January 26, 2021

Insert a file or the result from running an external program into the vim opened file

Suppose you have a file open in the vim and you want to insert output of some shell command into the file instead of closing the file or leaving the current terminal :read can be utilized to directly append the output of shell command into the file.

The :read command can insert a file or the result from running an external program into the current buffer. In case of the shell command it has to be prefixed with the !

Examples:

:read !openssl rand -hex 32 :read /etc/passwd