Saturday, February 19, 2011

RE: Multiple Substitutes for 'includeexpr'


 
> From: zyx.vim@gmail.com
> To: vim_use@googlegroups.com
> Subject: Re: Multiple Substitutes for 'includeexpr'
> Date: Sun, 20 Feb 2011 03:02:21 +0300
>
> Reply to message «Multiple Substitutes for 'includeexpr'»,
> sent 02:11:23 20 February 2011, Sunday
> by Roy Fulbright:
>
> > I tried adding a
> > second substitute to the assignment, separated by the vertical bar (|),
> > but this generates an error message while processing .vimrc.
> What do you mean by adding second substitute?
> set includeexpr=substitute(...)\|substitute(...)
> ? This won't work: assume that it runs `let includefile={put inputexpr here}'.
> Would you really write this with bar? You can use nested substitutes, but it is
> not required here:
> let &l:includeexpr='substitute(v:fname, "::", "/", "g").".pm"'
> Another warnings:
> 1. Using `:set' for local options. I know that this is what was written in
> example, but you should use `:setlocal'.
> 2. You do not require to escape colon, escape in example escapes dot that means
> `any character except newline' in unescaped state.
> 3. Using `let &l:optname=...' instead of `setlocal optname=' is more readable.
>
> Original message:
> > I am trying to use the 'gf' command to open the file containing the Perl
> > module in a "use AB::CD::Module" statement. I included the following line
> > in my .vimrc:
> >
> > set includeexpr=substitute(v:fname,'\\::','/','g')
> >
> > This translates the double colons to slashes in f:fname to form the path
> > name, but I also need to add '.pm' to the end of v:fname. I tried adding a
> > second substitute to the assignment, separated by the vertical bar (|),
> > but this generates an error message while processing .vimrc.
> >
> > How can I apply more than one substitute to v:fname during the assignment
> > to 'includeexpr'?
> >
> > Thanks,
> > Roy Fulbright

Thanks, ZyX. Your solution works fine, although I've discovered that I'm going to have to
modify the path(s) vim searches to find the module. How can I display the paths that
vim searches when issuing the 'gf' command?
 

No comments: