django.vim (4142B)
1 " Vim syntax file 2 " Language: Django template 3 " Maintainer: Dave Hodder <dmh@dmh.org.uk> 4 " Last Change: 2021 Nov 29 5 " 2026 Feb 12 by Vim Project add partial support #19386 6 7 " quit when a syntax file was already loaded 8 if exists("b:current_syntax") 9 finish 10 endif 11 12 syntax case match 13 14 " Mark illegal characters 15 syn match djangoError "%}\|}}\|#}" 16 17 " Django template built-in tags and parameters 18 " 'comment' doesn't appear here because it gets special treatment 19 syn keyword djangoStatement contained autoescape csrf_token empty 20 " FIXME ==, !=, <, >, <=, and >= should be djangoStatements: 21 " syn keyword djangoStatement contained == != < > <= >= 22 syn keyword djangoStatement contained and as block endblock by cycle debug else elif 23 syn keyword djangoStatement contained extends filter endfilter firstof for 24 syn keyword djangoStatement contained endfor if endif ifchanged endifchanged 25 syn keyword djangoStatement contained ifequal endifequal ifnotequal 26 syn keyword djangoStatement contained endifnotequal in include load not now or 27 syn keyword djangoStatement contained parsed regroup reversed spaceless 28 syn keyword djangoStatement contained endspaceless ssi templatetag openblock 29 syn keyword djangoStatement contained closeblock openvariable closevariable 30 syn keyword djangoStatement contained openbrace closebrace opencomment 31 syn keyword djangoStatement contained closecomment widthratio url with endwith 32 syn keyword djangoStatement contained get_current_language trans noop blocktrans 33 syn keyword djangoStatement contained endblocktrans get_available_languages 34 syn keyword djangoStatement contained get_current_language_bidi plural 35 syn keyword djangoStatement contained translate blocktranslate endblocktranslate 36 syn keyword djangoStatement contained partialdef endpartialdef partial 37 38 " Django templete built-in filters 39 syn keyword djangoFilter contained add addslashes capfirst center cut date 40 syn keyword djangoFilter contained default default_if_none dictsort 41 syn keyword djangoFilter contained dictsortreversed divisibleby escape escapejs 42 syn keyword djangoFilter contained filesizeformat first fix_ampersands 43 syn keyword djangoFilter contained floatformat get_digit join last length length_is 44 syn keyword djangoFilter contained linebreaks linebreaksbr linenumbers ljust 45 syn keyword djangoFilter contained lower make_list phone2numeric pluralize 46 syn keyword djangoFilter contained pprint random removetags rjust slice slugify 47 syn keyword djangoFilter contained safe safeseq stringformat striptags 48 syn keyword djangoFilter contained time timesince timeuntil title truncatechars 49 syn keyword djangoFilter contained truncatewords truncatewords_html unordered_list upper urlencode 50 syn keyword djangoFilter contained urlize urlizetrunc wordcount wordwrap yesno 51 52 " Keywords to highlight within comments 53 syn keyword djangoTodo contained TODO FIXME XXX 54 55 " Django template constants (always surrounded by double quotes) 56 syn region djangoArgument contained start=/"/ skip=/\\"/ end=/"/ 57 58 " Mark illegal characters within tag and variables blocks 59 syn match djangoTagError contained "#}\|{{\|[^%]}}\|[&#]" 60 syn match djangoVarError contained "#}\|{%\|%}\|[<>!&#%]" 61 62 " Django template tag and variable blocks 63 syn region djangoTagBlock start="{%" end="%}" contains=djangoStatement,djangoFilter,djangoArgument,djangoTagError display 64 syn region djangoVarBlock start="{{" end="}}" contains=djangoFilter,djangoArgument,djangoVarError display 65 66 " Django template 'comment' tag and comment block 67 syn region djangoComment start="{%\s*comment\(\s\+.\{-}\)\?%}" end="{%\s*endcomment\s*%}" contains=djangoTodo 68 syn region djangoComBlock start="{#" end="#}" contains=djangoTodo 69 70 " Define the default highlighting. 71 " Only when an item doesn't have highlighting yet 72 73 hi def link djangoTagBlock PreProc 74 hi def link djangoVarBlock PreProc 75 hi def link djangoStatement Statement 76 hi def link djangoFilter Identifier 77 hi def link djangoArgument Constant 78 hi def link djangoTagError Error 79 hi def link djangoVarError Error 80 hi def link djangoError Error 81 hi def link djangoComment Comment 82 hi def link djangoComBlock Comment 83 hi def link djangoTodo Todo 84 85 86 let b:current_syntax = "django"