为了账号安全,请及时绑定邮箱和手机立即绑定

html.vim

标签:
Html/CSS

 " Vim syntax file

" Language: HTML" Maintainer: Claudio Fleiner <claudio@fleiner.com>" URL: http://www.fleiner.com/vim/syntax/html.vim" Last Change:  2006 Jun 19 " Please check :help html.vim for some comments and a description of the options " For version 5.x: Clear all syntax items" For version 6.x: Quit when a syntax file was already loadedif !exists("main_syntax")  if version < 600    syntax clear  elseif exists("b:current_syntax")    finish  endif  let main_syntax = 'html'endif " don't use standard HiLink, it will not work with included syntax filesif version < 508  command! -nargs=+ HtmlHiLink hi link <args>else  command! -nargs=+ HtmlHiLink hi def link <args>endif syntax spell toplevel syn case ignore " mark illegal characterssyn match htmlError "[<>&]"  " tagssyn region  htmlString   contained start=+"+ end=+"+ contains=htmlSpecialChar,javaScriptExpression,@htmlPreprocsyn region  htmlString   contained start=+'+ end=+'+ contains=htmlSpecialChar,javaScriptExpression,@htmlPreprocsyn match   htmlValue    contained "=[\t ]*[^'" \t>][^ \t>]*"hs=s+1   contains=javaScriptExpression,@htmlPreprocsyn region  htmlEndTag             start=+</+      end=+>+ contains=htmlTagN,htmlTagErrorsyn region  htmlTag                start=+<[^/]+   end=+>+ contains=htmlTagN,htmlString,htmlArg,htmlValue,htmlTagError,htmlEvent,htmlCssDefinition,@htmlPreproc,@htmlArgClustersyn match   htmlTagN     contained +<\s*[-a-zA-Z0-9]\++hs=s+1 contains=htmlTagName,htmlSpecialTagName,@htmlTagNameClustersyn match   htmlTagN     contained +</\s*[-a-zA-Z0-9]\++hs=s+2 contains=htmlTagName,htmlSpecialTagName,@htmlTagNameClustersyn match   htmlTagError contained "[^>]<"ms=s+1  " tag namessyn keyword htmlTagName contained address applet area a base basefontsyn keyword htmlTagName contained big blockquote br caption centersyn keyword htmlTagName contained cite code dd dfn dir div dl dt fontsyn keyword htmlTagName contained form hr html imgsyn keyword htmlTagName contained input isindex kbd li link map menusyn keyword htmlTagName contained meta ol option param pre p samp spansyn keyword htmlTagName contained select small strike sub supsyn keyword htmlTagName contained table td textarea th tr tt ul var xmpsyn match htmlTagName contained "\<\(b\|i\|u\|h[1-6]\|em\|strong\|head\|body\|title\)\>" " new html 4.0 tagssyn keyword htmlTagName contained abbr acronym bdo button col labelsyn keyword htmlTagName contained colgroup del fieldset iframe ins legendsyn keyword htmlTagName contained object optgroup q s tbody tfoot thead " legal arg namessyn keyword htmlArg contained actionsyn keyword htmlArg contained align alink alt archive background bgcolorsyn keyword htmlArg contained border bordercolor cellpaddingsyn keyword htmlArg contained cellspacing checked class clear code codebase colorsyn keyword htmlArg contained cols colspan content coords enctype facesyn keyword htmlArg contained gutter height hspace idsyn keyword htmlArg contained link lowsrc marginheightsyn keyword htmlArg contained marginwidth maxlength method name promptsyn keyword htmlArg contained rel rev rows rowspan scrolling selected shapesyn keyword htmlArg contained size src start target text type urlsyn keyword htmlArg contained usemap ismap valign value vlink vspace width wrapsyn match   htmlArg contained "\<\(http-equiv\|href\|title\)="me=e-1 " Netscape extensionssyn keyword htmlTagName contained frame noframes frameset nobr blinksyn keyword htmlTagName contained layer ilayer nolayer spacersyn keyword htmlArg     contained frameborder noresize pagex pagey above belowsyn keyword htmlArg     contained left top visibility clip id noshadesyn match   htmlArg     contained "\<z-index\>" " Microsoft extensionssyn keyword htmlTagName contained marquee " html 4.0 arg namessyn match   htmlArg contained "\<\(accept-charset\|label\)\>"syn keyword htmlArg contained abbr accept accesskey axis char charoff charsetsyn keyword htmlArg contained cite classid codetype compact data datetimesyn keyword htmlArg contained declare defer dir disabled for framesyn keyword htmlArg contained headers hreflang lang language longdescsyn keyword htmlArg contained multiple nohref nowrap object profile readonlysyn keyword htmlArg contained rules scheme scope span standby stylesyn keyword htmlArg contained summary tabindex valuetype version " special characterssyn match htmlSpecialChar "&#\=[0-9A-Za-z]\{1,8};" " Comments (the real ones or the old netscape ones)if exists("html_wrong_comments")  syn region htmlComment                start=+<!--+    end=+--\s*>+else  syn region htmlComment                start=+<!+      end=+>+   contains=htmlCommentPart,htmlCommentError  syn match  htmlCommentError contained "[^><!]"  syn region htmlCommentPart  contained start=+--+      end=+--\s*+  contains=@htmlPreProcendifsyn region htmlComment                  start=+<!DOCTYPE+ keepend end=+>+ " server-parsed commandssyn region htmlPreProc start=+<!--#+ end=+-->+ contains=htmlPreStmt,htmlPreError,htmlPreAttrsyn match htmlPreStmt contained "<!--#\(config\|echo\|exec\|fsize\|flastmod\|include\|printenv\|set\|if\|elif\|else\|endif\|geoguide\)\>"syn match htmlPreError contained "<!--#\S*"ms=s+4syn match htmlPreAttr contained "\w\+=[^"]\S\+" contains=htmlPreProcAttrError,htmlPreProcAttrNamesyn region htmlPreAttr contained start=+\w\+="+ skip=+\\\\\|\\"+ end=+"+ contains=htmlPreProcAttrName keependsyn match htmlPreProcAttrError contained "\w\+="he=e-1syn match htmlPreProcAttrName contained "\(expr\|errmsg\|sizefmt\|timefmt\|var\|cgi\|cmd\|file\|virtual\|value\)="he=e-1 if !exists("html_no_rendering")  " rendering  syn cluster htmlTop contains=@Spell,htmlTag,htmlEndTag,htmlSpecialChar,htmlPreProc,htmlComment,htmlLink,javaScript,@htmlPreproc   syn region htmlBold start="<b\>" end="</b>"me=e-4 contains=@htmlTop,htmlBoldUnderline,htmlBoldItalic  syn region htmlBold start="<strong\>" end="</strong>"me=e-9 contains=@htmlTop,htmlBoldUnderline,htmlBoldItalic  syn region htmlBoldUnderline contained start="<u\>" end="</u>"me=e-4 contains=@htmlTop,htmlBoldUnderlineItalic  syn region htmlBoldItalic contained start="<i\>" end="</i>"me=e-4 contains=@htmlTop,htmlBoldItalicUnderline  syn region htmlBoldItalic contained start="<em\>" end="</em>"me=e-5 contains=@htmlTop,htmlBoldItalicUnderline  syn region htmlBoldUnderlineItalic contained start="<i\>" end="</i>"me=e-4 contains=@htmlTop  syn region htmlBoldUnderlineItalic contained start="<em\>" end="</em>"me=e-5 contains=@htmlTop  syn region htmlBoldItalicUnderline contained start="<u\>" end="</u>"me=e-4 contains=@htmlTop,htmlBoldUnderlineItalic   syn region htmlUnderline start="<u\>" end="</u>"me=e-4 contains=@htmlTop,htmlUnderlineBold,htmlUnderlineItalic  syn region htmlUnderlineBold contained start="<b\>" end="</b>"me=e-4 contains=@htmlTop,htmlUnderlineBoldItalic  syn region htmlUnderlineBold contained start="<strong\>" end="</strong>"me=e-9 contains=@htmlTop,htmlUnderlineBoldItalic  syn region htmlUnderlineItalic contained start="<i\>" end="</i>"me=e-4 contains=@htmlTop,htmlUnderlineItalicBold  syn region htmlUnderlineItalic contained start="<em\>" end="</em>"me=e-5 contains=@htmlTop,htmlUnderlineItalicBold  syn region htmlUnderlineItalicBold contained start="<b\>" end="</b>"me=e-4 contains=@htmlTop  syn region htmlUnderlineItalicBold contained start="<strong\>" end="</strong>"me=e-9 contains=@htmlTop  syn region htmlUnderlineBoldItalic contained start="<i\>" end="</i>"me=e-4 contains=@htmlTop  syn region htmlUnderlineBoldItalic contained start="<em\>" end="</em>"me=e-5 contains=@htmlTop   syn region htmlItalic start="<i\>" end="</i>"me=e-4 contains=@htmlTop,htmlItalicBold,htmlItalicUnderline  syn region htmlItalic start="<em\>" end="</em>"me=e-5 contains=@htmlTop  syn region htmlItalicBold contained start="<b\>" end="</b>"me=e-4 contains=@htmlTop,htmlItalicBoldUnderline  syn region htmlItalicBold contained start="<strong\>" end="</strong>"me=e-9 contains=@htmlTop,htmlItalicBoldUnderline  syn region htmlItalicBoldUnderline contained start="<u\>" end="</u>"me=e-4 contains=@htmlTop  syn region htmlItalicUnderline contained start="<u\>" end="</u>"me=e-4 contains=@htmlTop,htmlItalicUnderlineBold  syn region htmlItalicUnderlineBold contained start="<b\>" end="</b>"me=e-4 contains=@htmlTop  syn region htmlItalicUnderlineBold contained start="<strong\>" end="</strong>"me=e-9 contains=@htmlTop   syn region htmlLink start="<a\>\_[^>]*\<href\>" end="</a>"me=e-4 contains=@Spell,htmlTag,htmlEndTag,htmlSpecialChar,htmlPreProc,htmlComment,javaScript,@htmlPreproc  syn region htmlH1 start="<h1\>" end="</h1>"me=e-5 contains=@htmlTop  syn region htmlH2 start="<h2\>" end="</h2>"me=e-5 contains=@htmlTop  syn region htmlH3 start="<h3\>" end="</h3>"me=e-5 contains=@htmlTop  syn region htmlH4 start="<h4\>" end="</h4>"me=e-5 contains=@htmlTop  syn region htmlH5 start="<h5\>" end="</h5>"me=e-5 contains=@htmlTop  syn region htmlH6 start="<h6\>" end="</h6>"me=e-5 contains=@htmlTop  syn region htmlHead start="<head\>" end="</head>"me=e-7 end="<body\>"me=e-5 end="<h[1-6]\>"me=e-3 contains=htmlTag,htmlEndTag,htmlSpecialChar,htmlPreProc,htmlComment,htmlLink,htmlTitle,javaScript,cssStyle,@htmlPreproc  syn region htmlTitle start="<title\>" end="</title>"me=e-8 contains=htmlTag,htmlEndTag,htmlSpecialChar,htmlPreProc,htmlComment,javaScript,@htmlPreprocendif syn keyword htmlTagName         contained noscriptsyn keyword htmlSpecialTagName  contained script styleif main_syntax != 'java' || exists("java_javascript")  " JAVA SCRIPT  syn include @htmlJavaScript syntax/javascript.vim  unlet b:current_syntax  syn region  javaScript start=+<script[^>]*>+ keepend end=+</script>+me=s-1 contains=@htmlJavaScript,htmlCssStyleComment,htmlScriptTag,@htmlPreproc  syn region  htmlScriptTag     contained start=+<script+ end=+>+       contains=htmlTagN,htmlString,htmlArg,htmlValue,htmlTagError,htmlEvent  HtmlHiLink htmlScriptTag htmlTag   " html events (i.e. arguments that include javascript commands)  if exists("html_extended_events")    syn region htmlEvent        contained start=+\<on\a\+\s*=[\t ]*'+ end=+'+ contains=htmlEventSQ    syn region htmlEvent        contained start=+\<on\a\+\s*=[\t ]*"+ end=+"+ contains=htmlEventDQ  else    syn region htmlEvent        contained start=+\<on\a\+\s*=[\t ]*'+ end=+'+ keepend contains=htmlEventSQ    syn region htmlEvent        contained start=+\<on\a\+\s*=[\t ]*"+ end=+"+ keepend contains=htmlEventDQ  endif  syn region htmlEventSQ        contained start=+'+ms=s+1 end=+'+me=s-1 contains=@htmlJavaScript  syn region htmlEventDQ        contained start=+"+ms=s+1 end=+"+me=s-1 contains=@htmlJavaScript  HtmlHiLink htmlEventSQ htmlEvent  HtmlHiLink htmlEventDQ htmlEvent   " a javascript expression is used as an arg value  syn region  javaScriptExpression contained start=+&{+ keepend end=+};+ contains=@htmlJavaScript,@htmlPreprocendif if main_syntax != 'java' || exists("java_vb")  " VB SCRIPT  syn include @htmlVbScript syntax/vb.vim  unlet b:current_syntax  syn region  javaScript start=+<script [^>]*language *=[^>]*vbscript[^>]*>+ keepend end=+</script>+me=s-1 contains=@htmlVbScript,htmlCssStyleComment,htmlScriptTag,@htmlPreprocendif syn cluster htmlJavaScript      add=@htmlPreproc if main_syntax != 'java' || exists("java_css")  " embedded style sheets  syn keyword htmlArg           contained media  syn include @htmlCss syntax/css.vim  unlet b:current_syntax  syn region cssStyle start=+<style+ keepend end=+</style>+ contains=@htmlCss,htmlTag,htmlEndTag,htmlCssStyleComment,@htmlPreproc  syn match htmlCssStyleComment contained "\(<!--\|-->\)"  syn region htmlCssDefinition matchgroup=htmlArg start='' contains=css.*Attr,css.*Prop,cssComment,cssLength,cssColor,cssURL,cssImportant,cssError,cssString,@htmlPreproc  HtmlHiLink htmlStyleArg htmlStringendif if main_syntax == "html"  " synchronizing (does not always work if a comment includes legal  " html tags, but doing it right would mean to always start  " at the first line, which is too slow)  syn sync match htmlHighlight groupthere NONE "<[/a-zA-Z]"  syn sync match htmlHighlight groupthere javaScript "<script"  syn sync match htmlHighlightSkip "^.*['\"].*$"  syn sync minlines=10endif " The default highlighting.if version >= 508 || !exists("did_html_syn_inits")  if version < 508    let did_html_syn_inits = 1  endif  HtmlHiLink htmlTag                     Function  HtmlHiLink htmlEndTag                  Identifier  HtmlHiLink htmlArg                     Type  HtmlHiLink htmlTagName                 htmlStatement  HtmlHiLink htmlSpecialTagName          Exception  HtmlHiLink htmlValue                     String  HtmlHiLink htmlSpecialChar             Special    if !exists("html_no_rendering")    HtmlHiLink htmlH1                      Title    HtmlHiLink htmlH2                      htmlH1    HtmlHiLink htmlH3                      htmlH2    HtmlHiLink htmlH4                      htmlH3    HtmlHiLink htmlH5                      htmlH4    HtmlHiLink htmlH6                      htmlH5    HtmlHiLink htmlHead                    PreProc    HtmlHiLink htmlTitle                   Title    HtmlHiLink htmlBoldItalicUnderline     htmlBoldUnderlineItalic    HtmlHiLink htmlUnderlineBold           htmlBoldUnderline    HtmlHiLink htmlUnderlineItalicBold     htmlBoldUnderlineItalic    HtmlHiLink htmlUnderlineBoldItalic     htmlBoldUnderlineItalic    HtmlHiLink htmlItalicUnderline         htmlUnderlineItalic    HtmlHiLink htmlItalicBold              htmlBoldItalic    HtmlHiLink htmlItalicBoldUnderline     htmlBoldUnderlineItalic    HtmlHiLink htmlItalicUnderlineBold     htmlBoldUnderlineItalic    HtmlHiLink htmlLink                    Underlined    if !exists("html_my_rendering")      hi def htmlBold                term=bold cterm=bold gui=bold      hi def htmlBoldUnderline       term=bold,underline cterm=bold,underline gui=bold,underline      hi def htmlBoldItalic          term=bold,italic cterm=bold,italic gui=bold,italic      hi def htmlBoldUnderlineItalic term=bold,italic,underline cterm=bold,italic,underline gui=bold,italic,underline      hi def htmlUnderline           term=underline cterm=underline gui=underline      hi def htmlUnderlineItalic     term=italic,underline cterm=italic,underline gui=italic,underline      hi def htmlItalic              term=italic cterm=italic gui=italic    endif  endif    HtmlHiLink htmlPreStmt            PreProc  HtmlHiLink htmlPreError           Error  HtmlHiLink htmlPreProc            PreProc  HtmlHiLink htmlPreAttr            String  HtmlHiLink htmlPreProcAttrName    PreProc  HtmlHiLink htmlPreProcAttrError   Error  HtmlHiLink htmlSpecial            Special  HtmlHiLink htmlSpecialChar        Special  HtmlHiLink htmlString             String  HtmlHiLink htmlStatement          Statement  HtmlHiLink htmlComment            Comment  HtmlHiLink htmlCommentPart        Comment  HtmlHiLink htmlValue              String  HtmlHiLink htmlCommentError       htmlError  HtmlHiLink htmlTagError           htmlError  HtmlHiLink htmlEvent              javaScript  HtmlHiLink htmlError              Error    HtmlHiLink javaScript             Special  HtmlHiLink javaScriptExpression   javaScript  HtmlHiLink htmlCssStyleComment    Comment  HtmlHiLink htmlCssDefinition      Specialendif delcommand HtmlHiLink let b:current_syntax = "html" if main_syntax == 'html'  unlet main_syntaxendif " vim: ts=8   "自动匹配HTML标签function! InsertHtmlTag()        let pat = '\c<\w\+\s*\(\s\+\w\+\s*=\s*[''#$;,()."a-z0-9]\+\)*\s*>'        normal! a>        let save_cursor = getpos('.')        let result = matchstr(getline(save_cursor[1]), pat)        "if (search(pat, 'b', save_cursor[1]) && searchpair('<','','>','bn',0,  getline('.')) > 0)        if (search(pat, 'b', save_cursor[1]))           normal! lyiwf>           normal! a</           normal! p           normal! a>        endif        :call cursor(save_cursor[1], save_cursor[2], save_cursor[3])endfunctioninoremap > <ESC>:call InsertHtmlTag()<CR>a

点击查看更多内容
TA 点赞

若觉得本文不错,就分享一下吧!

评论

作者其他优质文章

正在加载中
  • 推荐
  • 评论
  • 收藏
  • 共同学习,写下你的评论
感谢您的支持,我会继续努力的~
扫码打赏,你说多少就多少
赞赏金额会直接到老师账户
支付方式
打开微信扫一扫,即可进行扫码打赏哦
今天注册有机会得

100积分直接送

付费专栏免费学

大额优惠券免费领

立即参与 放弃机会
意见反馈 帮助中心 APP下载
官方微信

举报

0/150
提交
取消