Meino Christian Cramer wrote:
Hi,
I often need to place a header above a function defintion (C-source)
fpr documentational purposes.
What I treid is to write a short function for vim, which dioes insert
the text skeleton -- but I did not find any already existing function
in the API which does this for me. With :i I got weird effects --
sure my fault, but... .
How can I insert text via a script ?
Kind regards,
mcc
If your text is in a file on its own, you can use ":r" with a line
number (the number of the line after which to insert, or 0 for "before
first line", or . for "after cursor line", or $ for "after last line";
default is after cursor line) in the "range" position, i.e. just before
the r. The file name comes as an argument at the end.
Example (after line 5):
5r ~/template.txt
If your text is in a register, you can use ":put" with a line number
(again) in the range position and the register name (including ", which
must be escaped as \", for the default register; or + for the system
clipboard) after the ":put".
Example (before cursor line):
.-1put \"
See
:help :read
:help :put
Best regards,
Tony.