我正在进行angularjs开发,并在HTML中的标签中包含一大堆HTML ng-templates,如下所示:
<script type="text/ng-template" id="content_listing.html">
<div class="item_content">
<div class="horiz-nav-menu">
<h3> {{sectionName}} </h3>
<ul>
<li ng-repeat="navLink in navLinks"> <a href='#/{{navLink.Target}}' title='{{navLink.Tip}}'>{{navLink.Text}}</a> </li>
</ul>
</div>
</div>
</script>
我选择的编辑Vim没有正确地突出显示HTML,因为它位于脚本标记内,这非常令人讨厌。因此,我为Vim创建了一个自定义语法区域,并在/ syntax / html.vim之后将其填充到文件中,我已经确认在Vim启动时会对其进行处理:
unlet b:current_syntax
syn include @HTML $VIMRUNTIME/syntax/html.vim
syn region htmlTemplate start=+<script [^>]*type *=[^>]*text/ng-template[^>]*>+ keepend end=+</script>+me=s-1 contains=@HTML,htmlScriptTag,@htmlPreproc
问题是突出显示行为是不稳定的(Vim 7.2)。为了使突出显示正常工作,我必须做一些事情,例如向下滚动,以便带有HTML的部分滚动页面,然后向后滚动,点击:e重新加载文档等。此外,即使突出显示正确,当我去编辑标签内的HTML时,该块的突出显示将关闭。
我不是Vim语法高亮的专家......有没有人遇到类似的事情?在我看来,我的区域定义看起来很好......