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

Syntax folding for C

Expand Messages
  • Olaf Dabrunz
    Hello, will folding be included in the standard syntax file for C? I like the idea of being able to use set foldmethod=syntax out of the box. ... +++ c.vim
    Message 1 of 1 , Sep 26, 2004
    • 0 Attachment
      Hello,

      will folding be included in the standard syntax file for C? I like the
      idea of being able to use "set foldmethod=syntax" out of the box.

      Folding comments and blocks seems to be a good start:


      --- c.vim.orig 2004-09-27 04:46:16.000000000 +0200
      +++ c.vim 2004-09-27 04:48:01.951749537 +0200
      @@ -123,16 +123,18 @@
      syntax match cCommentSkip contained "^\s*\*\($\|\s\+\)"
      syntax region cCommentString contained start=+L\=\\\@<!"+ skip=+\\\\\|\\"+ end=+"+ end=+\*/+me=s-1 contains=cSpecial,cCommentSkip
      syntax region cComment2String contained start=+L\=\\\@<!"+ skip=+\\\\\|\\"+ end=+"+ end="$" contains=cSpecial
      - syntax region cCommentL start="//" skip="\\$" end="$" keepend contains=@cCommentGroup,cComment2String,cCharacter,cNumbersCom,cSpaceError,@Spell
      + syntax region cCommentL start="//" skip="\\$" end="$" keepend contains=@cCommentGroup,cComment2String,cCharacter,cNumbersCom,cSpaceError,@Spell fold
      syntax region cComment matchgroup=cCommentStart start="/\*" end="\*/" contains=@cCommentGroup,cCommentStartError,cCommentString,cCharacter,cNumbersCom,cSpaceError,@Spell
      else
      syn region cCommentL start="//" skip="\\$" end="$" keepend contains=@cCommentGroup,cSpaceError,@Spell
      - syn region cComment matchgroup=cCommentStart start="/\*" end="\*/" contains=@cCommentGroup,cCommentStartError,cSpaceError,@Spell
      + syn region cComment matchgroup=cCommentStart start="/\*" end="\*/" contains=@cCommentGroup,cCommentStartError,cSpaceError,@Spell fold
      endif
      " keep a // comment separately, it terminates a preproc. conditional
      syntax match cCommentError display "\*/"
      syntax match cCommentStartError display "/\*"me=e-1 contained

      +syn region cBlock_fold start="{" end="}" transparent fold
      +
      syn keyword cOperator sizeof
      if exists("c_gnu")
      syn keyword cStatement __asm__

      Regards,

      --
      Olaf Dabrunz (od/odabrunz), SUSE Linux AG, N├╝rnberg
    Your message has been successfully submitted and would be delivered to recipients shortly.