Copying One File into Another File within Vim

Vim has a wonderful :read (or short: :r) command that allows you to grab the contents of another file and paste it into the contents of the current editing session:

:read filename

For instance, let's say we have a file called homework.txt in a user's home directory, and we want to add its contents to the file we are currently editing. In vim we'd type:

:read /home/acortez/homework.txt

This will place the contents of /home/acortez/homework.txt into the current file.

Tags

 vim