2010-03-01 42 views
6

我正在嘗試爲cf.vim創建一個修補程序來解決散列問題。在ColdFusion中,#標誌用於包含cfoutput塊內的表達式。ColdFusion散列標記的vim語法高亮顯示

<cfset x = 1 /> 
<cfoutput> x is now #x# </cfoutput> 
<!--- outputs "x is now 1" ---> 

問題進場時,有一個孤獨的#,不是cfoutput塊內:

<a href="#x">an anchored link</a> 

這將導致VIM突出#後一切就好像它是一個cfHashRegion

syn region cfHashRegion start=+#+ skip=+"[^"]*"\|'[^']*'+ end=+#+ contained containedin=cfOutputRegion [email protected],cfScriptParenError 

syn region cfOutputRegion matchgroup=NONE transparent start=+<cfoutput>+ end=+</cfoutput>+ contains=TOP 

有什麼我可以添加到cfHashRegion告訴VIM「不要進入cfHashRegion除非找到兩者的開始和結束的屬性

超級獎金:cfoutput只是最常見的方式要在「cfOutputRegion」。任何cffunction與輸出=「真」的行爲就好像它的塊中的一切都被包裹在cfoutput標籤。

回答

2

您是否嘗試過使用syn match代替syn region?我不知道的ColdFusion語法,所以我不會知道這是我可能/正確。

喜歡的東西:

syn region cfHashRegion "L\=#[^#]+#" containedin=cfOutputRegion [email protected],cfScriptParenError 

您可能還需要考慮使用一些情況下,contains=ALLBUT,{group-name},..參數列表。

+0

我不得不逃脫+,但它的工作。它並不完美,因爲'cfHashRegion'實際上可以分成多行。但實際上,它們幾乎總是在一條線上。謝謝! – mwcz 2010-03-06 17:59:39

+1

我將此添加到我的Vim插件以獲得更好的CF支持https://github.com/davejlong​​/cf-utils.vim – 2012-06-13 13:57:21