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

Env Vars in Makefile have () so gf does not work

Expand Messages
  • Wes
    Hi, I haven t found an answer to this on the web. Hopefully you guys can help. I love the gf and gF commands but unfortunately they don t work in
    Message 1 of 3 , Mar 22, 2011
      Hi,

      I haven't found an answer to this on the web. Hopefully you guys can
      help.

      I love the 'gf' and 'gF' commands but unfortunately they don't work in
      Makefiles, which I edit a lot. The reason is that environment
      variables have to have () in the name, such as:

      $(MYENVAR)/iocompare/src/iocompare.jar

      Is there a slick way to make this work? I thought about modifying
      isfname but even if I can get vim to recognize the whole string as a
      file, the parens would still mess up the file search.

      Thanks,
      Wes

      --
      You received this message from the "vim_use" maillist.
      Do not top-post! Type your reply below the text you are replying to.
      For more information, visit http://www.vim.org/maillist.php
    • Jürgen Krämer
      Hi, ... apart from ... Whenever you press gf or gF on a file name Vim will execute substitute(v:fname, $( ( w + )) , $ 1 , g ) with v:fname set to the
      Message 2 of 3 , Mar 23, 2011
        Hi,

        Wes wrote:
        >
        > I haven't found an answer to this on the web. Hopefully you guys can
        > help.
        >
        > I love the 'gf' and 'gF' commands but unfortunately they don't work in
        > Makefiles, which I edit a lot. The reason is that environment
        > variables have to have () in the name, such as:
        >
        > $(MYENVAR)/iocompare/src/iocompare.jar
        >
        > Is there a slick way to make this work? I thought about modifying
        > isfname but even if I can get vim to recognize the whole string as a
        > file, the parens would still mess up the file search.

        apart from

        :set isfname+=(,)

        you have to set the 'includeexpr' option:

        :set includeexpr=substitute(v:fname,\ '$(\\(\\w\\+\\))',\ '$\\1',\ 'g')

        Whenever you press 'gf' or 'gF' on a file name Vim will execute

        substitute(v:fname, '$(\(\w\+\))', '$\1', 'g')

        with v:fname set to the text under the cursor. This command just removes
        the parentheses around the name of the environment variable. The
        remaining $MYENVVAR is then expanded by Vim's default routines for 'gf',
        'gF', etc.

        Regards,
        Jürgen

        --
        Sometimes I think the surest sign that intelligent life exists elsewhere
        in the universe is that none of it has tried to contact us. (Calvin)

        --
        You received this message from the "vim_use" maillist.
        Do not top-post! Type your reply below the text you are replying to.
        For more information, visit http://www.vim.org/maillist.php
      • Wes
        It works! Love ya Jurgen, and vim! -- You received this message from the vim_use maillist. Do not top-post! Type your reply below the text you are replying
        Message 3 of 3 , Apr 1, 2011
          It works!
          Love ya Jurgen, and vim!

          --
          You received this message from the "vim_use" maillist.
          Do not top-post! Type your reply below the text you are replying to.
          For more information, visit http://www.vim.org/maillist.php
        Your message has been successfully submitted and would be delivered to recipients shortly.