Writing a vim function to insert a block of static text
function, vim
Solution
I do that by keeping under my vim folder a set of files which then I insert using the `r` command (which inserts the contents of a file, at the current location if no line number is passed) from some function:
function! Class()
" ~/vim/cpp/new-class.txt is the path to the template file
r~/vim/cpp/new-class.txt
endfunction
This is very practical - in my opinion - when you want to insert multi-line text. Then you can, for example, map a keyboard shortcut to call your function:
nmap ^N :call Class()<CR>
Problem
I'd like to be able to do something like this in vim (you can assume v7+ if it helps). Type in a command like this (or something close) ``` :inshtml ``` and have vim dump the following into the current file at the current cursor location ``` <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title></title> </head> <body> </body> </html> ``` Can I write a vim function do this is? Is there a better way?