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