Loading ...
Sorry, an error occurred while loading the content.

76026Re: question on gf and path

Expand Messages
  • Ben K.
    Dec 4, 2006
    • 0 Attachment
      It worked and I appreciate the simpleness. Thanks.


      On Fri, 1 Dec 2006, Tim Chase wrote:

      >> Is there a way to make gf open "some.file" from this line?
      >>
      >> Include("/includes/some.file");
      >>
      >> where the file is actually sitting under web server root, like
      >>
      >>
      >> /var/www/html/includes/some.file
      >>
      >> I tried adding "/var/www/html" to the :set path but vim will
      >> not recognize it. /var/www/html/; was the same. Basically I'm
      >> looking for a way to add "prefixes".
      >
      > Assuming you have "/var/www/html" in your path, the following
      > pairing should help you out:
      >
      >
      > nnoremap <silent> gf :exec 'e ' . findfile(substitute(expand('<cfile>'),
      > '^/*','',''))<cr>
      >
      > nnoremap <silent> <c-w>f :exec 'sp ' . findfile(substitute(expand('<cfile>'),
      > '^/*','',''))<cr>
      >
      > The findfile() function also takes an extra parameter if you want
      > to refrain from munging your actual path, you could do something like
      >
      > findfile(..., &path.',/var/www/html')
      >
      >> On the same note, would it be possible to let gf open
      >>
      >> /var/www/html/includes/some.file
      >>
      >> when I gf on this string
      >>
      >> http://somehost.com/includes/some.file
      >>
      >> or by defining a new command (say wf)?
      >
      > A similar transformation could tweak the previous, something like
      >
      > substitute(expand(...), '^\(http://[^/]/\)\=/*','','')
      >
      > would strip off leading slashes and leading protocol+host. (that
      > regexp/substitute() is untested, but should be approx. correct, save for
      > possible needs to escape the "\" characters)
      >
      > Alternatively, you could map it to <leader>gf and <leader><c-w>f
      > to maintain the original meanings, but create new mappings to
      > provide the additional functionality.
      >
      > HTH,
      >
      > -tim
      >
      >
      >
      >
      >

      Regards,

      Ben K.
      Developer
      http://benix.tamu.edu
    • Show all 7 messages in this topic