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

Re: vim + ctags for C++ problem

Expand Messages
  • Jacek Czaja
    Thank you very much for your answer! Regards, Jacek -- -- You received this message from the vim_use maillist. Do not top-post! Type your reply below the
    Message 1 of 4 , Apr 24, 2013
      Thank you very much for your answer!

      Regards,
      Jacek

      --
      --
      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

      ---
      You received this message because you are subscribed to the Google Groups "vim_use" group.
      To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
      For more options, visit https://groups.google.com/groups/opt_out.
    • Charles Campbell
      ... Adding the -n flag will fix this, at the price that: if you insert a new line somewhere into your file, the line numbers will also change, thereby
      Message 2 of 4 , Apr 24, 2013
        Ben Fritz wrote:
        > On Tuesday, April 23, 2013 3:20:29 AM UTC-5, Jacek Czaja wrote:
        >> And now my cursor is somewhere in main function and I want to jump to beta::b definition so I do:
        >>
        >> :ta beta::b
        >>
        >> and vim jumps to alpha::b ???
        >>
        >>
        >> When I print possibilities:
        >>
        >> :ts
        >>
        >> it is something like:
        >> beta::b
        >> class:beta access:public
        >> int b;
        >>
        >> So :ts properly is showing the jump location but for some reason calling it via:
        >>
        >> :ta beta::b
        >>
        >>
        >> gives me wrong result.
        >>
        >> All this problem happns only if I have two or more classes definition in the same file. If they are spread around diffrent files then it is all fine.
        >>
        > I generated tags from your file using the ctags command you gave, and I can reproduce the problem.
        >
        > I also see the cause.
        >
        > With the options you give, the tag file entries for alpha::b and beta::b both have the same search pattern. Here are their entries:
        >
        > alpha::b .\test.cpp /^ int b;$/;" m class:alpha file: access:private
        > beta::b .\test.cpp /^ int b;$/;" m class:beta file: access:public
        >
        > I'm not sure whether this can be fixed.
        >
        > I know the tagbar plugin ( http://www.vim.org/scripts/script.php?script_id=3465 ) can correctly jump to each tag, but I don't know how this is accomplished. You could look into the plugin or contact the author.
        >
        > Certainly, you could also post-process your tags file to modify the search pattern. This may be how tagbar does it, I do not know.
        >
        > If I manually edit the generated tags file to include a search for the class before a search for the tag itself, I can correctly jump to beta::b and alpha::b with the :tag command:
        >
        > alpha::b .\test.cpp /class alpha/;/^ int b;$/;" m class:alpha file: access:private
        > beta::b .\test.cpp /class beta/;/^ int b;$/;" m class:beta file: access:public
        >
        > Note my introduction of /class alpha/; and /class beta/; to perform a double search in each case.
        >
        > This could certainly be automated, since the class name is right in the tag definition. I'll leave that to you.
        >
        Adding the "-n" flag will fix this, at the price that: if you insert a
        new line somewhere into your file, the line numbers will also change,
        thereby silently invalidating the tags file.
        I suggest putting comments on the two identical lines that differentiate
        them.

        Regards,
        C Campbell

        --
        --
        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

        ---
        You received this message because you are subscribed to the Google Groups "vim_use" group.
        To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
        For more options, visit https://groups.google.com/groups/opt_out.
      Your message has been successfully submitted and would be delivered to recipients shortly.