vim语法高亮和语法折叠怎么兼具?
发表于 : 2011-01-29 18:26
我用vim编辑matlab,想同时实现语法高亮和语法折叠。但似乎同一个关键字不能同时被标记为高亮关键字和region的start/end匹配字符。
例如,如果我单独定义:
syn region matlabFoldBlock start='\<classdef\>\|\<methods\>\|\<events\>\|\<properties\>\|\<if\>\|\<while\>\|\<for\>\|\<switch\>\|\<try\>\|\<function\>' end='\(([^()]*\)\@!\<end\>\([^()]*)\)\@!' contains=ALL fold transparent
没有语法高亮,但所有的折叠都是正确的。只要同时定义了:
syn keyword matlabStatement return function
syn keyword matlabConditional switch case else elseif end if otherwise break continue
syn keyword matlabRepeat do for while
syn keyword matlabStorageClass classdef methods properties events persistent global
syn keyword matlabExceptions try catch rethrow throw
这些关键字可以高亮,但折叠就都没有了。
有没有办法可以同时实现语法高亮和语法折叠?我知道表达式折叠、记号折叠、缩进折叠能work around,但就是想知道语法折叠怎么实现。
谢谢先。
例如,如果我单独定义:
syn region matlabFoldBlock start='\<classdef\>\|\<methods\>\|\<events\>\|\<properties\>\|\<if\>\|\<while\>\|\<for\>\|\<switch\>\|\<try\>\|\<function\>' end='\(([^()]*\)\@!\<end\>\([^()]*)\)\@!' contains=ALL fold transparent
没有语法高亮,但所有的折叠都是正确的。只要同时定义了:
syn keyword matlabStatement return function
syn keyword matlabConditional switch case else elseif end if otherwise break continue
syn keyword matlabRepeat do for while
syn keyword matlabStorageClass classdef methods properties events persistent global
syn keyword matlabExceptions try catch rethrow throw
这些关键字可以高亮,但折叠就都没有了。
有没有办法可以同时实现语法高亮和语法折叠?我知道表达式折叠、记号折叠、缩进折叠能work around,但就是想知道语法折叠怎么实现。
谢谢先。