home *** CD-ROM | disk | FTP | other *** search
/ vim.ftp.fu-berlin.de / 2015-02-03.vim.ftp.fu-berlin.de.tar / vim.ftp.fu-berlin.de / runtime / syntax / matlab.vim < prev    next >
Encoding:
Text File  |  2011-05-27  |  4.2 KB  |  126 lines

  1. " Vim syntax file
  2. " Language:    Matlab
  3. " Maintainer:    Maurizio Tranchero - maurizio(.)tranchero(@)gmail(.)com
  4. " Credits:    Preben 'Peppe' Guldberg <peppe-vim@wielders.org>
  5. "        Original author: Mario Eusebio
  6. " Last Change:    Wed Jan 13 11:12:34 CET 2010
  7. "         sinh added to matlab implicit commands
  8. " Change History:
  9. "         - 'global' and 'persistent' keyword are now recognized
  10.  
  11. " For version 5.x: Clear all syntax items
  12. " For version 6.x: Quit when a syntax file was already loaded
  13. if version < 600
  14.   syntax clear
  15. elseif exists("b:current_syntax")
  16.   finish
  17. endif
  18.  
  19. syn keyword matlabStatement        return
  20. syn keyword matlabLabel            case switch
  21. syn keyword matlabConditional        else elseif end if otherwise
  22. syn keyword matlabRepeat        do for while
  23. " MT_ADDON - added exception-specific keywords
  24. syn keyword matlabExceptions        try catch
  25. syn keyword matlabOO            classdef properties events methods
  26.  
  27. syn keyword matlabTodo            contained  TODO
  28. syn keyword matlabScope            global persistent
  29.  
  30. " If you do not want these operators lit, uncommment them and the "hi link" below
  31. syn match matlabArithmeticOperator    "[-+]"
  32. syn match matlabArithmeticOperator    "\.\=[*/\\^]"
  33. syn match matlabRelationalOperator    "[=~]="
  34. syn match matlabRelationalOperator    "[<>]=\="
  35. syn match matlabLogicalOperator        "[&|~]"
  36.  
  37. syn match matlabLineContinuation    "\.\{3}"
  38.  
  39. "syn match matlabIdentifier        "\<\a\w*\>"
  40.  
  41. " String
  42. " MT_ADDON - added 'skip' in order to deal with 'tic' escaping sequence 
  43. syn region matlabString            start=+'+ end=+'+    oneline skip=+''+
  44.  
  45. " If you don't like tabs
  46. syn match matlabTab            "\t"
  47.  
  48. " Standard numbers
  49. syn match matlabNumber        "\<\d\+[ij]\=\>"
  50. " floating point number, with dot, optional exponent
  51. syn match matlabFloat        "\<\d\+\(\.\d*\)\=\([edED][-+]\=\d\+\)\=[ij]\=\>"
  52. " floating point number, starting with a dot, optional exponent
  53. syn match matlabFloat        "\.\d\+\([edED][-+]\=\d\+\)\=[ij]\=\>"
  54.  
  55. " Transpose character and delimiters: Either use just [...] or (...) aswell
  56. syn match matlabDelimiter        "[][]"
  57. "syn match matlabDelimiter        "[][()]"
  58. syn match matlabTransposeOperator    "[])a-zA-Z0-9.]'"lc=1
  59.  
  60. syn match matlabSemicolon        ";"
  61.  
  62. syn match matlabComment            "%.*$"    contains=matlabTodo,matlabTab
  63. " MT_ADDON - correctly highlights words after '...' as comments
  64. syn match matlabComment            "\.\.\..*$"    contains=matlabTodo,matlabTab
  65. syn region matlabMultilineComment    start=+%{+ end=+%}+ contains=matlabTodo,matlabTab
  66.  
  67. syn keyword matlabOperator        break zeros default margin round ones rand
  68. syn keyword matlabOperator        ceil floor size clear zeros eye mean std cov
  69.  
  70. syn keyword matlabFunction        error eval function
  71.  
  72. syn keyword matlabImplicit        abs acos atan asin cos cosh exp log prod sum
  73. syn keyword matlabImplicit        log10 max min sign sin sinh sqrt tan reshape
  74.  
  75. syn match matlabError    "-\=\<\d\+\.\d\+\.[^*/\\^]"
  76. syn match matlabError    "-\=\<\d\+\.\d\+[eEdD][-+]\=\d\+\.\([^*/\\^]\)"
  77.  
  78. " Define the default highlighting.
  79. " For version 5.7 and earlier: only when not done already
  80. " For version 5.8 and later: only when an item doesn't have highlighting yet
  81. if version >= 508 || !exists("did_matlab_syntax_inits")
  82.   if version < 508
  83.     let did_matlab_syntax_inits = 1
  84.     command -nargs=+ HiLink hi link <args>
  85.   else
  86.     command -nargs=+ HiLink hi def link <args>
  87.   endif
  88.  
  89.   HiLink matlabTransposeOperator    matlabOperator
  90.   HiLink matlabOperator            Operator
  91.   HiLink matlabLineContinuation        Special
  92.   HiLink matlabLabel            Label
  93.   HiLink matlabConditional        Conditional
  94.   HiLink matlabExceptions        Conditional
  95.   HiLink matlabRepeat            Repeat
  96.   HiLink matlabTodo            Todo
  97.   HiLink matlabString            String
  98.   HiLink matlabDelimiter        Identifier
  99.   HiLink matlabTransposeOther        Identifier
  100.   HiLink matlabNumber            Number
  101.   HiLink matlabFloat            Float
  102.   HiLink matlabFunction            Function
  103.   HiLink matlabError            Error
  104.   HiLink matlabImplicit            matlabStatement
  105.   HiLink matlabStatement        Statement
  106.   HiLink matlabOO            Statement
  107.   HiLink matlabSemicolon        SpecialChar
  108.   HiLink matlabComment            Comment
  109.   HiLink matlabMultilineComment        Comment
  110.   HiLink matlabScope            Type
  111.  
  112.   HiLink matlabArithmeticOperator    matlabOperator
  113.   HiLink matlabRelationalOperator    matlabOperator
  114.   HiLink matlabLogicalOperator        matlabOperator
  115.  
  116. "optional highlighting
  117.   "HiLink matlabIdentifier        Identifier
  118.   "HiLink matlabTab            Error
  119.  
  120.   delcommand HiLink
  121. endif
  122.  
  123. let b:current_syntax = "matlab"
  124.  
  125. "EOF    vim: ts=8 noet tw=100 sw=8 sts=0
  126.