【问题标题】:Vim syntax file to be stricter about HTML syntaxVim 语法文件对 HTML 语法更严格
【发布时间】:2011-05-02 20:50:19
【问题描述】:

我刚刚被一个错误所咬

 <link rel=stylesheet" type="text/css" href="stylesheet.css" media="all">

而不是

 <link rel="stylesheet" type="text/css" href="stylesheet.css" media="all">

似乎 vim 的 html 语法高亮并没有区分两者。我可以从某个地方获得更严格的语法文件吗?

(对于仇恨者:vim questions belong on stackoverflow, not superuser

【问题讨论】:

    标签: html vim syntax-highlighting strict


    【解决方案1】:

    作为权宜之计,我将$VIMRUNTIME/syntax/html.vim 的副本放在~/.vim/syntax/html.vim 中并对其进行了修改:

    38c38
    < syn match   htmlValue    contained "=[\t ]*[^'" \t>][^ \t>]*"hs=s+1   contains=javaScriptExpression,@htmlPreproc
    ---
    > syn match   htmlValue    contained /=[\t ]*\%('\%(\\.\|[^\\']\)*'\|"\%(\\.\|[^\\"]\)*\|[^'" \t>]*\)/hs=s+1   contains=htmlString,javaScriptExpression,@htmlPreproc
    40c40
    < syn region  htmlTag                start=+<[^/]+   end=+>+ contains=htmlTagN,htmlString,htmlArg,htmlValue,htmlTagError,htmlEvent,htmlCssDefinition,@htmlPreproc,@htmlArgCluster
    ---
    > syn region  htmlTag                start=+<[^/]+   end=+>+ contains=htmlTagN,htmlArg,htmlValue,htmlTagError,htmlEvent,htmlCssDefinition,@htmlPreproc,@htmlArgCluster
    43a44
    > syn match   htmlTagError contained /['"].*/
    168c169
    <   syn region  htmlScriptTag     contained start=+<script+ end=+>+       contains=htmlTagN,htmlString,htmlArg,htmlValue,htmlTagError,htmlEvent
    ---
    >   syn region  htmlScriptTag     contained start=+<script+ end=+>+       contains=htmlTagN,htmlArg,htmlValue,htmlTagError,htmlEvent
    

    这只是捕捉到这个特定的错误(不匹配的引号),所以我仍然对严格 html 的更好语法文件非常感兴趣。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-10-01
      • 2011-08-27
      • 2012-11-18
      • 1970-01-01
      • 2011-04-20
      • 2013-08-01
      相关资源
      最近更新 更多