With :read
we can read the content of a file into our buffer at the position
of the cursor. It can be useful when we want to merge files together. Maybe the
prominent usage is to write code snippets in different files and just :read
them into a code block in a markdown file.
With :read !
we can even read the output of a shell command and insert it into
our buffer at the position of the cursor.
Examples
" Read the content of snippet.go into the buffer.
:read snippet.go
" Insert the list of files under done/ into the buffer.
:read !ls
" Insert a calendar into the buffer.
:read !cal
" Download and insert ssh keys into the buffer from GitHub.
:read !curl -sL https://github.com/yitsushi.keys