Tuesday, February 22, 2011
RE: v:fname mods
> From: zyx.vim@gmail.com
> To: vim_use@googlegroups.com
> Subject: Re: v:fname mods
> Date: Tue, 22 Feb 2011 18:34:25 +0300
>
> Reply to message «Re: v:fname mods»,
> sent 18:23:59 22 February 2011, Tuesday
> by ZyX:
>
> Sorry, no match groups here, just referencing the whole matched pattern in a
> second substitute. If `let &l:includeexpr="..."' does not work, use `setlocal
> includeexpr=...' with proper escaping.
>
> Original message:
> > Reply to message «v:fname mods»,
> > sent 15:32:51 22 February 2011, Tuesday
> >
> > by Roy Fulbright:
> > > How can I modify v:fname to contain: A/B/C/Mymodule/Mymodule.pm (note:
> > > the last part of the path is duplicated before adding '.pm') I used
> > > 'substitute' to replace '::' with '/'. I looked for a vim function to
> > > parse pathname in order to get the last part, but found nothing.
> >
> > There is a function that parses paths: fnamemodify, expression that gets
> > last part of a path: fnamemodify(path, ':t'). But there is probably a
> > better solution either using match groups or defining a new function with
> > split+join:
> >
> > let
> > &l:includeexpr='substitute(substitute(v:fname,"::","/","g"),"[^/]\\+$","&/&
> > .pm","g")'
> >
> > Original message:
> > > I have a fullpath filename in v:fname minus the filetype, for example:
> > > A::B::C::Mymodule
> > >
> > > How can I modify v:fname to contain: A/B/C/Mymodule/Mymodule.pm (note:
> > > the last part of the path is duplicated before adding '.pm') I used
> > > 'substitute' to replace '::' with '/'. I looked for a vim function to
> > > parse pathname in order to get the last part, but found nothing.
> > >
> > > My ultimate goal is to set 'includeexpr' to an expression that will
> > > convert the object of a Perl "use" command to a filename for 'gf'.
Thank you very much. The substitute in a substitute worked great! I only had to remove
a couple extra charcters from the end of the substitute string (> ) before the '.pm'.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment