Saturday, February 19, 2011

Re: Multiple Substitutes for 'includeexpr'

Reply to message «Re: Multiple Substitutes for 'includeexpr'»,
sent 02:44:00 20 February 2011, Sunday
by ZyX:

By the way, you do not need to modify anything if you use perl-support plugin:
it sets correct includeexpr option (strange, but it uses nested substitutes
('substitute(substitute(v:fname,''::'',''/'',''g''),''$'',''.pm'','''')')
instead of a simple string concatenation like I suggested).

Original message:
> 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

No comments: