【发布时间】:2010-01-29 22:18:24
【问题描述】:
我一直在尝试关注instructions on the Vim wiki 来获取 matchit 插件,以使用包含在 MacVim 上运行的 ColdFusion 和 HTML 标签的 ColdFusion (*.cfm) 文件。
我在 $HOME/.vim/syntax/cf.vim 中安装了 ColdFusion (cf.vim) 的语法文件,在 .vim/plugin/matchit.vim 中安装了最新版本的 matchit,并且我'在 matchit.vim 的末尾添加了以下块:
au FileType html,jsp,php,cf if !exists("b:match_words") |
我还在 $HOME/.vimrc 文件的末尾添加了以下行:
filetype plugin on
最后我将建议的块添加到 cf.vim 的末尾:
" Only do this when not done yet for this buffer
if exists("b:did_ftplugin")
finish
endif
" Don't load another plugin for this buffer
let b:did_ftplugin = 1
if exists("loaded_matchit")
let b:match_words = '<cfif\>.\{-}>\|<cfif\>.\{-}$:'
\ . '<cfelseif\>.\{-}>\|<cfelseif\>.\{-}$:'
\ . '<cfelse\>.\{-}>\|<cfelse\>.\{-}$:'
\ . '<\/cfif>,'
\ . '<cfloop\>.\{-}>\|<cfloop\>.\{-}$:'
\ . '<\/cfloop\>.\{-}>,'
\ . '<cfoutput\>.\{-}>\|<cfoutput\>.\{-}$:'
\ . '<\/cfoutput\>.\{-}>,'
\ . '<cftimer\>.\{-}>\|<cftimer\>.\{-}$:'
\ . '<\/cftimer\>.\{-}>,'
\ . '<!---:--->,'
\ . '<cfquery\>.\{-}>\|<cfquery\>.\{-}$:<\/cfquery\>.\{-}>,'
\ . '<cfscript>:<\/cfscript>'
" Since we are counting things outside of comments only,
" It is important we account comments accurately or match_words
" will be wrong and therefore useless
syntax sync fromstart
endif " exists("loaded_matchit")
但是,当我按 % 键跳转到匹配的标签时,它只工作了一半,具体取决于文件扩展名。例如,如果文件具有 .cfm 扩展名,我可以从 <cfif> 跳转到 </cfif>,但不能从 <body> 跳转到 </body>。如果扩展名为 .html,则情况相反。
但是从 cf.vim 的代码来看,它似乎应该与混合在同一个文件中的 ColdFusion 和 HTML 标签一起使用:
" Inherit syntax rules from the standard HTML syntax file
if version < 600
source <sfile>:p:h/html.vim
else
runtime! syntax/html.vim
endif
在我添加的相关说明中:
let b:match_ignorecase = 1
到 $HOME/.vimrc 以禁用文档中所述的区分大小写,但它仍然仅适用于 cfif 而不是 CFIF 例如。
【问题讨论】:
标签: vim syntax plugins coldfusion editor