English 中文(简体)
我如何才能禁用 Vim S HTML 错误突出显示?
原标题:How can I disable Vim s HTML error highlighting?

我用 Vim 来编辑包含嵌入宏的 HTML, 其中宏以双角度括号括号括在括号内, 例如 : “ & lt; & gt; ” 。 Vim S 标准 HTML 突出显示将第二个“ <” 和“ & gt;” 视为错误, 并突出显示错误 。 我如何能防止这些错误? 我很乐意教给 $VIMHOM/ syntax/ html. vim 双角括号可以确定, 或者简单地禁用错误突出显示, 但我不确定如何做 。 (“ 高亮清除 htmlTagError ” 没有效果 。 事实上, “ 亮亮清除” 在 HTML 缓冲中没有效果 。

问题回答

如果您想要在您的宏中引入完整的语法突出显示, 启动语法文件( 如 < code> htmldjango ( $MURUNTIME/ syntax/ htmldjango. vim ), 使用同一目录的 < code> html. vim 和 < code> django. vim ) 将是最容易的。 在其中, < code_...\\\ \ / code > 中, 有特殊的含义, 除其他外。 您想要同样的含义, 但有 < code_lt; < 和 < codecode\gt; & gt;

只需突出显示 , 您就需要这样的语法行 :

syntax region mylangMacro start="<<" end=">>" containedin=ALLBUT,mylangMacro

然后你可以用下列方式突出它:

highlight default link mylangMacro Macro

这可以在中进行,也可以在htmldjango 的样式下作为新的语法提示器进行(这是我首选的办法;然后您可以让 HTML 文件使用这个带有自动立体的新的语法文件)。


(您也可以用 htmlTagError < /code> 来清除以类似位置显示的 < code> syntax clear htmlTagError < /code> 突出显示的错误。 但希望您会认为单独显示比仅仅删除错误要好。 )

以下是编辑 Vim 中现有语法突出显示的指示 :

http://vimdoc.sourceforge.net/htmldoc/syntax.html#mysyntaxfile-add' rel=“nofollow'>http://vimdoc.sourceforge.net/htmldoc/syntax.html#mysyntaxfile-add

Unix/ Linux 的 vim 运行时间路径 :

                   $HOME/.vim,
                    $VIM/vimfiles,
                    $VIMRUNTIME,
                    $VIM/vimfiles/after,
                    $HOME/.vim/after

在您的 vim 运行时路径中创建名为“ after/ syngat” 的目录 。

Unix/ Linux 命令 :

mkdir ~/.vim/after
mkdir ~/.vim/after/syntax
  1. Write a Vim script that contains the commands you want to use. For example, to change the colors for the C syntax: highlight cComment ctermfg=Green guifg=Green

  2. Write that file in the "after/syntax" directory. Use the name of the syntax, with ".vim" added. For our C syntax: :w ~/.vim/after/syntax/c.vim

That s it. The next time you edit a C file the Comment color will be different. You don t even have to restart Vim.

If you have multiple files, you can use the filetype as the directory name. All the "*.vim" files in this directory will be used, for example: ~/.vim/after/syntax/c/one.vim ~/.vim/after/syntax/c/two.vim

或者,您可以选择一个容易得多的路线,并在纳诺命令行编辑器内使用语法加亮,您可以很容易地用常规表达式来定义自己的语法:

< a href=" "http://how-to.wikia.com/wiki/ How_to_use_syntax_highlighting_with_the_GNU_nano_text_editor" rel=“no follow" >http://ho-to.wikia.com/wiki/ How_to_use_syntax_highlighting_with_the_GNU_nano_text_editor





相关问题
CSS working only in Firefox

I am trying to create a search text-field like on the Apple website. The HTML looks like this: <div class="frm-search"> <div> <input class="btn" type="image" src="http://www....

image changed but appears the same in browser

I m writing a php script to crop an image. The script overwrites the old image with the new one, but when I reload the page (which is supposed to pickup the new image) I still see the old one. ...

Firefox background image horizontal centering oddity

I am building some basic HTML code for a CMS. One of the page-related options in the CMS is "background image" and "stretch page width / height to background image width / height." so that with large ...

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签