Friday, November 25, 2011

Re: Open a file whose name is selected after a search pattern in the current line

It's hard to tell from your example exactly what the pattern is that
you're looking to match, but since you said that's not the difficult
part, I'll just assume you're more interested in the general principle
and not the specific regex. So here's my approach, which works with the
example lines you provided:

nnoremap <Leader>f :execute 'edit' substitute(getline('.'), '\v.*\w{3}\.(\w+)\.\w{3}', '\1', '') . '.txt'<CR>

Of course, you can use any key mapping, I just arbitrarily picked
<Leader>f for the sake of example.

No comments:

Post a Comment