Back references in Vim scripts

Is there any way, in a vim script, to get "dollar digit" variables such as those used in Perl to extract matched text? I have the following:

function GotoCFile() if search('^\s*#\s*cfile:\s*\(\w\+\)')

" $1 is not the variable in vim exe "echo 'Found ".$1."'" else exe "echo 'Could not find name of corresponding file'" endendfunction

I'm trying to find a Perl comment like this:

# cfile: somefile

And assign "somefile" to a variable. I've searched all over the Vim documentation for this and it seems to involve finding the starting and ending positions of the match and doing a bit of math and a extracting a substring. Tell me it's not this hard!

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
Without JavaScript enabled, you might want to
use the classic discussion system instead. If you login, you can remember this preference.

I'm not sure I'd say that I've learned it. When I started at Rentrak, they already had,gi,gt,t and,T. I just copy/paste/tweaked from there for the most part. Before I started at Rentrak, I'd primarily been a BBEdit user, with ten-year-rusty vi experience. Rentrak was the first place I used Vim.

> Is there a decent tutorial out there or did you go through the docs

There may well be a decent tutorial. If so, I never found it. Instead I spent way to much time banging m

Thanks! That's useful information. I have to admit, I'm thinking about Emacs just because I find the Vim docs so intensely painful. I'm not Stephen Hawking, but I'm not particularly stupid, either. I don't know why I have such trouble with the Vim docs, but I do. This really should have not been so hard to figure out:/