Reputation: 2111
I want to create a file with a block of code in it and then, when I open a new file, this block is already in the file without having to copy paste every time. Something like:
:e newfile.cpp/template.cpp
where I now have a new file named newfile.cpp and it has the contents of template.cpp in it; template.cpp will just sit in my directory and wont be changed unless I open it specifically.
Upvotes: 0
Views: 150
Reputation: 172500
If rely on templates a lot, you probably need something more advanced. There are several such plugins on vim.org; one is tSkeleton.
Upvotes: 0
Reputation: 161604
Use |
(bar) to concate two commands:
:e newfile.cpp | r template.cpp
Upvotes: 2
Reputation: 59277
You can leave your template opened and use:
:saveas newfile.cpp
Or, use one snippets plugin like snipMate or XPTemplate to implement a similar functionality.
Upvotes: 1
Reputation: 41232
One generic possibility is simply to use this command:
:r template.cpp
Upvotes: 3