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

Confusing the auto-indenter!

Expand Messages
  • Gary Holloway
    Take the following code snippet: // cindent // cinoptions=:0,c1,(0,f0,p0,t0 // shiftwidth=5 main() { static const char foo[] = **/**/** ; /* This is a comment
    Message 1 of 1 , Nov 30, 2001
    • 0 Attachment
      Take the following code snippet:

      // cindent
      // cinoptions=:0,c1,(0,f0,p0,t0
      // shiftwidth=5

      main()
      {
      static const char foo[] = "**/**/**";

      /* This is a comment that spans more than one line; the indentation of C
      * source below this comment gets messed up due to the string above.
      */
      hello
      }


      Note the column "hello" is in (it *should* be one column to the left); vim
      indented it there, and == will indent it there.

      Now change the value of foo, so it looks like:

      static const char foo[] = "foo";

      Now hit == on the "hello" line... it indents it as expected.

      Apparently the "/*" or */" (or both?) in the string is confusing vim's sense of
      indentation!

      Bug?

      -gary

      p.s., Needless to say, in the actual code, it took me a while to figure out
      what was causing the indentaion strangeness since the string wasn't
      particularly close to where I was editing. :(
    Your message has been successfully submitted and would be delivered to recipients shortly.