While in vi how can I pull in / insert / paste the contents of another file
Type the following
:r filename_to_paste
This will paste the contents of the file after the line on which the cursor is present.
If you need to copy/paste smaller range of lines/block of text from one file to other, you can also do the following assuming one file is opened in vim
already
- Open 2nd file using
:sp
(split) or:vsp
(vertical split) - do a normal
yy
(yank) commands in the other file - do
p
(paste) command back in the 1st file, as the register (place where yanked text is stored) is common to both the files. - Press Ctrl+w twice to switch between splited files.