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

Re: Proper handling of C style // comments?

Expand Messages
  • Hugh Sasse
    ... The 7.2 syntax/c.vim uses the tag cCommentL for this, and the highlight association looks like hi def link cCommentL cComment (if I ve got that
    Message 1 of 8 , Mar 2, 2011
    • 0 Attachment
      On Wed, 2 Mar 2011, kuru wrote:

      > Hi
      >
      > Currently when ever I open .c files, "//" comment lines show up as
      > "errors" based on the color syntax. I have tried the latest c.vim from
      > last November which seems to resolve the issue but that one is
      > relatively shorter and not as extended as the previous c.vim syntax
      > file. So I am trying to find the offending lines in the older c.vim
      > and resolve the mishandling. The only thing is that I am not so
      > profound with the expressions in the syntax files. And I just cannt
      > figure out how to fix it. I am hoping that someone might be able to
      > help me out here

      The 7.2 syntax/c.vim uses the tag cCommentL for this, and the highlight
      association looks like
      hi def link cCommentL cComment
      (if I've got that right.) Try looking for something like that, maybe with
      cError instead of cComment, as it's showing as an error.

      I'm not an expert, so ignore this if someone actually fluent in this stuff
      responds.
      >
      >
      > thanks
      >
      > kerem
      >
      Hugh

      --
      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
    • Christian Brabandt
      Hi kuru! ... Where did you get this syntax file from? It doesn t happen here with the latest Vim runtime file and also not with Vim 7.2. So you might need to
      Message 2 of 8 , Mar 2, 2011
      • 0 Attachment
        Hi kuru!

        On Mi, 02 Mär 2011, kuru wrote:

        > Currently when ever I open .c files, "//" comment lines show up as
        > "errors" based on the color syntax. I have tried the latest c.vim from
        > last November which seems to resolve the issue but that one is
        > relatively shorter and not as extended as the previous c.vim syntax
        > file. So I am trying to find the offending lines in the older c.vim
        > and resolve the mishandling. The only thing is that I am not so
        > profound with the expressions in the syntax files. And I just cannt
        > figure out how to fix it. I am hoping that someone might be able to
        > help me out here

        Where did you get this syntax file from? It doesn't happen here with the
        latest Vim runtime file and also not with Vim 7.2.

        So you might need to investigate the syntax file. On the
        //-comment line, enter the following line:
        :echomsg synIDattr(synID(line("."), col("."), 1), "name")
        It should output something like cComment
        Now open the syntax file and search for that item. There should be a
        line like this:
        hi def link cComment <item>

        Now in your .vimrc put this:
        " Fix annoying // Comments in C files:
        hi link cComment Comment

        regards,
        Christian

        --
        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
      • kuru
        Hugh thanks for your time, but that one did not help me ;) Christian, that was a great solution. It did do the trick. My c.vim is from 2006, I am not using the
        Message 3 of 8 , Mar 2, 2011
        • 0 Attachment
          Hugh thanks for your time, but that one did not help me ;)

          Christian, that was a great solution. It did do the trick. My c.vim is
          from 2006, I am not using the latest one(from nov 2010 by Bram)
          because the older one is more extended in a way and I already created
          my color file.

          It was called CCommentError, so I diverted it to comment as you have
          suggested.

          Thanks again. that was great work around. it does not take care of the
          root of the problem but it is a great solution





          On Mar 2, 11:49 am, Christian Brabandt <cbli...@...> wrote:
          > Hi kuru!
          >
          > On Mi, 02 M r 2011, kuru wrote:
          >
          > > Currently when ever I open .c files, "//" comment lines show up as
          > > "errors" based on the color syntax. I have tried the latest c.vim from
          > > last November which seems to resolve the issue but that one is
          > > relatively shorter and not as extended as the previous c.vim syntax
          > > file. So I am trying to find the offending lines in the older c.vim
          > > and resolve the mishandling. The only thing is that I am not so
          > > profound with the expressions in the syntax files. And I just cannt
          > > figure out how to fix it.  I am hoping that someone might be able to
          > > help me out here
          >
          > Where did you get this syntax file from? It doesn't happen here with the
          > latest Vim runtime file and also not with Vim 7.2.
          >
          > So you might need to investigate the syntax file. On the
          > //-comment line, enter the following line:
          > :echomsg synIDattr(synID(line("."), col("."), 1), "name")
          > It should output something like cComment
          > Now open the syntax file and search for that item. There should be a
          > line like this:
          > hi def link cComment <item>
          >
          > Now in your .vimrc  put this:
          > " Fix annoying // Comments in C files:
          > hi link cComment Comment
          >
          > regards,
          > Christian

          --
          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
        • Ben Fritz
          ... And where did you get this older file? ... It sure seems like it s intentionally using error highlight then. You should figure out why it is matching
          Message 4 of 8 , Mar 3, 2011
          • 0 Attachment
            On Mar 2, 4:32 pm, kuru <maymunbe...@...> wrote:
            > Hugh thanks for your time, but that one did not help me ;)
            >
            > Christian, that was a great solution. It did do the trick. My c.vim is
            > from 2006, I am not using the latest one(from nov 2010 by Bram)
            > because the older one is more extended in a way and I already created
            > my color file.
            >

            And where did you get this older file?

            > It was called CCommentError, so I diverted it to comment as you have
            > suggested.
            >

            It sure seems like it's intentionally using error highlight then. You
            should figure out why it is matching there. Perhaps your extended
            syntax file matches '//' style comments as errors since they are not
            technically part of standard C (they're called "c++ style" where I
            work).

            --
            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
          • Zvezdan Petkovic
            ... FWIW, // comments are in the official C standard. C99 standard is now almost 12 years old. -- You received this message from the vim_use maillist. Do
            Message 5 of 8 , Mar 3, 2011
            • 0 Attachment
              On Mar 3, 2011, at 6:18 PM, Ben Fritz wrote:

              > It sure seems like it's intentionally using error highlight then. You
              > should figure out why it is matching there. Perhaps your extended
              > syntax file matches '//' style comments as errors since they are not
              > technically part of standard C (they're called "c++ style" where I
              > work).

              FWIW, '//' comments are in the official C standard.
              C99 standard is now almost 12 years old.

              --
              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
            • kuru
              Ben In the latest vim C syntax file it is corrected, I mean it does not highlight double slashes as error. So I presumed that it was a mistake in the original
              Message 6 of 8 , Mar 3, 2011
              • 0 Attachment
                Ben

                In the latest vim C syntax file it is corrected, I mean it does not
                highlight double slashes as error. So I presumed that it was a mistake
                in the original version

                On Mar 3, 5:18 pm, Ben Fritz <fritzophre...@...> wrote:
                > On Mar 2, 4:32 pm, kuru <maymunbe...@...> wrote:
                >
                > > Hugh thanks for your time, but that one did not help me ;)
                >
                > > Christian, that was a great solution. It did do the trick. My c.vim is
                > > from 2006, I am not using the latest one(from nov 2010 by Bram)
                > > because the older one is more extended in a way and I already created
                > > my color file.
                >
                > And where did you get this older file?
                >
                > > It was called CCommentError, so I diverted it to comment as you have
                > > suggested.
                >
                > It sure seems like it's intentionally using error highlight then. You
                > should figure out why it is matching there. Perhaps your extended
                > syntax file matches '//' style comments as errors since they are not
                > technically part of standard C (they're called "c++ style" where I
                > work).

                --
                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
              • Mike Williams
                ... I would guess it is my extended C syntax highlighter: http://www.vim.org/scripts/script.php?script_id=234 To allow // comments just add the following to
                Message 7 of 8 , Mar 4, 2011
                • 0 Attachment
                  On 03/03/2011 23:18, Ben Fritz wrote:
                  >
                  >
                  > On Mar 2, 4:32 pm, kuru<maymunbe...@...> wrote:
                  >> Hugh thanks for your time, but that one did not help me ;)
                  >>
                  >> Christian, that was a great solution. It did do the trick. My c.vim is
                  >> from 2006, I am not using the latest one(from nov 2010 by Bram)
                  >> because the older one is more extended in a way and I already created
                  >> my color file.
                  >>
                  >
                  > And where did you get this older file?

                  I would guess it is my extended C syntax highlighter:

                  http://www.vim.org/scripts/script.php?script_id=234

                  To allow // comments just add the following to your .vimrc file:

                  let c_cpp_comments = 1

                  There is a help file included in the download that explains all the
                  settings.

                  >> It was called CCommentError, so I diverted it to comment as you have
                  >> suggested.
                  >>
                  >
                  > It sure seems like it's intentionally using error highlight then. You
                  > should figure out why it is matching there. Perhaps your extended
                  > syntax file matches '//' style comments as errors since they are not
                  > technically part of standard C (they're called "c++ style" where I
                  > work).
                  >

                  --
                  Mike

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