function! template(text)
" Do something with the text and return the result
What I would like to do now is to be able to press a key let say F5 in
visual mode and the text that I have selected should be passed into the
text variable of the template function.
Is this possible? I don't want to have to manually yank the text before
I pass it.
Well, you mention not wanting to manually yank the
text...however, if it was automatically yanked into a register
for you, would that be okay? Or do you not want to touch the
unnamed register at all? If the former is okay, something like
:vnoremap <f4> c<c-r>=Template(@")<cr><esc>
might do the trick for you. (note "Template" rather than
"template" as function names are supposed to start with an
uppercase letter or "s:" as describe at ":help E125")
-tim