" Vim syntax file" Language: Python" Maintainer: Dmitry Vasiliev <dima at hlabs dot org>" URL: https://github.com/hdima/vim-scripts/blob/master/syntax/python/python.vim" Last Change: 2012年02月11日" Filenames: *.py" Version: 2.6.7"" Based on python.vim (from Vim 6.1 distribution)" by Neil Schemenauer <nas at python dot ca>"" Thanks:"" Jeroen Ruigrok van der Werven" for the idea to highlight erroneous operators" Pedro Algarvio" for the patch to enable spell checking only for the right spots" (strings and comments)" John Eikenberry" for the patch fixing small typo" Caleb Adamantine" for the patch fixing highlighting for decorators" Andrea Riciputi" for the patch with new configuration options"" Options:"" For set option do: let OPTION_NAME = 1" For clear option do: let OPTION_NAME = 0"" Option names:"" For highlight builtin functions and objects:" python_highlight_builtins"" For highlight builtin objects:" python_highlight_builtin_objs"" For highlight builtin funtions:" python_highlight_builtin_funcs"" For highlight standard exceptions:" python_highlight_exceptions"" For highlight string formatting:" python_highlight_string_formatting"" For highlight str.format syntax:" python_highlight_string_format"" For highlight string.Template syntax:" python_highlight_string_templates"" For highlight indentation errors:" python_highlight_indent_errors"" For highlight trailing spaces:" python_highlight_space_errors"" For highlight doc-tests:" python_highlight_doctests"" If you want all Python highlightings above:" python_highlight_all" (This option not override previously set options)"" For fast machines:" python_slow_sync"" For "print" builtin as function:" python_print_as_function" For version 5.x: Clear all syntax items" For version 6.x: Quit when a syntax file was already loadedif version < 600syntax clearelseif exists("b:current_syntax")finishendifif exists("python_highlight_all") && python_highlight_all != 0" Not override previously set optionsif !exists("python_highlight_builtins")if !exists("python_highlight_builtin_objs")let python_highlight_builtin_objs = 1endifif !exists("python_highlight_builtin_funcs")let python_highlight_builtin_funcs = 1endifendifif !exists("python_highlight_exceptions")let python_highlight_exceptions = 1endifif !exists("python_highlight_string_formatting")let python_highlight_string_formatting = 1endifif !exists("python_highlight_string_format")let python_highlight_string_format = 1endifif !exists("python_highlight_string_templates")let python_highlight_string_templates = 1endifif !exists("python_highlight_indent_errors")let python_highlight_indent_errors = 1endifif !exists("python_highlight_space_errors")let python_highlight_space_errors = 1endifif !exists("python_highlight_doctests")let python_highlight_doctests = 1endifendif" Keywordssyn keyword pythonStatement break continue delsyn keyword pythonStatement exec returnsyn keyword pythonStatement pass raisesyn keyword pythonStatement global assertsyn keyword pythonStatement lambda yieldsyn keyword pythonStatement withsyn keyword pythonStatement def class nextgroup=pythonFunction skipwhitesyn match pythonFunction "[a-zA-Z_][a-zA-Z0-9_]*" display containedsyn keyword pythonRepeat for whilesyn keyword pythonConditional if elif elsesyn keyword pythonPreCondit import from assyn keyword pythonException try except finallysyn keyword pythonOperator and in is not orif !exists("python_print_as_function") || python_print_as_function == 0syn keyword pythonStatement printendif" Decorators (new in Python 2.4)syn match pythonDecorator "@" display nextgroup=pythonDottedName skipwhitesyn match pythonDottedName "[a-zA-Z_][a-zA-Z0-9_]*\(\.[a-zA-Z_][a-zA-Z0-9_]*\)*" display containedsyn match pythonDot "\." display containedin=pythonDottedName" Commentssyn match pythonComment "#.*$" display contains=pythonTodo,@Spellsyn match pythonRun "\%^#!.*$"syn match pythonCoding "\%^.*\(\n.*\)\?#.*coding[:=]\s*[0-9A-Za-z-_.]\+.*$"syn keyword pythonTodo TODO FIXME XXX contained" Errorssyn match pythonError "\<\d\+\D\+\>" displaysyn match pythonError "[$?]" displaysyn match pythonError "[&|]\{2,}" displaysyn match pythonError "[=]\{3,}" display" TODO: Mixing spaces and tabs also may be used for pretty formatting multiline" statements. For now I don't know how to work around this.if exists("python_highlight_indent_errors") && python_highlight_indent_errors != 0syn match pythonIndentError "^\s*\( \t\|\t \)\s*\S"me=e-1 displayendif" Trailing space errorsif exists("python_highlight_space_errors") && python_highlight_space_errors != 0syn match pythonSpaceError "\s\+$" displayendif" Stringssyn region pythonString start=+[bB]\='+ skip=+\\\\\|\\'\|\\$+ excludenl end=+'+ end=+$+ keepend contains=pythonEscape,pythonEscapeError,@Spellsyn region pythonString start=+[bB]\="+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"+ end=+$+ keepend contains=pythonEscape,pythonEscapeError,@Spellsyn region pythonString start=+[bB]\="""+ end=+"""+ keepend contains=pythonEscape,pythonEscapeError,pythonDocTest2,pythonSpaceError,@Spellsyn region pythonString start=+[bB]\='''+ end=+'''+ keepend contains=pythonEscape,pythonEscapeError,pythonDocTest,pythonSpaceError,@Spellsyn match pythonEscape +\\[abfnrtv'"\\]+ display containedsyn match pythonEscape "\\\o\o\=\o\=" display containedsyn match pythonEscapeError "\\\o\{,2}[89]" display containedsyn match pythonEscape "\\x\x\{2}" display containedsyn match pythonEscapeError "\\x\x\=\X" display containedsyn match pythonEscape "\\$"" Unicode stringssyn region pythonUniString start=+[uU]'+ skip=+\\\\\|\\'\|\\$+ excludenl end=+'+ end=+$+ keepend contains=pythonEscape,pythonUniEscape,pythonEscapeError,pythonUniEscapeError,@Spellsyn region pythonUniString start=+[uU]"+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"+ end=+$+ keepend contains=pythonEscape,pythonUniEscape,pythonEscapeError,pythonUniEscapeError,@Spellsyn region pythonUniString start=+[uU]"""+ end=+"""+ keepend contains=pythonEscape,pythonUniEscape,pythonEscapeError,pythonUniEscapeError,pythonDocTest2,pythonSpaceError,@Spellsyn region pythonUniString start=+[uU]'''+ end=+'''+ keepend contains=pythonEscape,pythonUniEscape,pythonEscapeError,pythonUniEscapeError,pythonDocTest,pythonSpaceError,@Spellsyn match pythonUniEscape "\\u\x\{4}" display containedsyn match pythonUniEscapeError "\\u\x\{,3}\X" display containedsyn match pythonUniEscape "\\U\x\{8}" display containedsyn match pythonUniEscapeError "\\U\x\{,7}\X" display containedsyn match pythonUniEscape "\\N{[A-Z ]\+}" display containedsyn match pythonUniEscapeError "\\N{[^A-Z ]\+}" display contained" Raw stringssyn region pythonRawString start=+[rR]'+ skip=+\\\\\|\\'\|\\$+ excludenl end=+'+ end=+$+ keepend contains=pythonRawEscape,@Spellsyn region pythonRawString start=+[rR]"+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"+ end=+$+ keepend contains=pythonRawEscape,@Spellsyn region pythonRawString start=+[rR]"""+ end=+"""+ keepend contains=pythonDocTest2,pythonSpaceError,@Spellsyn region pythonRawString start=+[rR]'''+ end=+'''+ keepend contains=pythonDocTest,pythonSpaceError,@Spellsyn match pythonRawEscape +\\['"]+ display transparent contained" Unicode raw stringssyn region pythonUniRawString start=+[uU][rR]'+ skip=+\\\\\|\\'\|\\$+ excludenl end=+'+ end=+$+ keepend contains=pythonRawEscape,pythonUniRawEscape,pythonUniRawEscapeError,@Spellsyn region pythonUniRawString start=+[uU][rR]"+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"+ end=+$+ keepend contains=pythonRawEscape,pythonUniRawEscape,pythonUniRawEscapeError,@Spellsyn region pythonUniRawString start=+[uU][rR]"""+ end=+"""+ keepend contains=pythonUniRawEscape,pythonUniRawEscapeError,pythonDocTest2,pythonSpaceError,@Spellsyn region pythonUniRawString start=+[uU][rR]'''+ end=+'''+ keepend contains=pythonUniRawEscape,pythonUniRawEscapeError,pythonDocTest,pythonSpaceError,@Spellsyn match pythonUniRawEscape "\([^\\]\(\\\\\)*\)\@<=\\u\x\{4}" display containedsyn match pythonUniRawEscapeError "\([^\\]\(\\\\\)*\)\@<=\\u\x\{,3}\X" display containedif exists("python_highlight_string_formatting") && python_highlight_string_formatting != 0" String formattingsyn match pythonStrFormatting "%\(([^)]\+)\)\=[-#0 +]*\d*\(\.\d\+\)\=[hlL]\=[diouxXeEfFgGcrs%]" contained containedin=pythonString,pythonUniString,pythonRawString,pythonUniRawStringsyn match pythonStrFormatting "%[-#0 +]*\(\*\|\d\+\)\=\(\.\(\*\|\d\+\)\)\=[hlL]\=[diouxXeEfFgGcrs%]" contained containedin=pythonString,pythonUniString,pythonRawString,pythonUniRawStringendifif exists("python_highlight_string_format") && python_highlight_string_format != 0" str.format syntaxsyn match pythonStrFormat "{{\|}}" contained containedin=pythonString,pythonUniString,pythonRawString,pythonUniRawStringsyn match pythonStrFormat "{\([a-zA-Z_][a-zA-Z0-9_]*\|\d\+\)\(\.[a-zA-Z_][a-zA-Z0-9_]*\|\[\(\d\+\|[^!:\}]\+\)\]\)*\(![rs]\)\=\(:\({\([a-zA-Z_][a-zA-Z0-9_]*\|\d\+\)}\|\([^}]\=[<>=^]\)\=[ +-]\=#\=0\=\d*\(\.\d\+\)\=[bcdeEfFgGnoxX%]\=\)\=\)\=}" contained containedin=pythonString,pythonUniString,pythonRawString,pythonUniRawStringendifif exists("python_highlight_string_templates") && python_highlight_string_templates != 0" String templatessyn match pythonStrTemplate "\$\$" contained containedin=pythonString,pythonUniString,pythonRawString,pythonUniRawStringsyn match pythonStrTemplate "\${[a-zA-Z_][a-zA-Z0-9_]*}" contained containedin=pythonString,pythonUniString,pythonRawString,pythonUniRawStringsyn match pythonStrTemplate "\$[a-zA-Z_][a-zA-Z0-9_]*" contained containedin=pythonString,pythonUniString,pythonRawString,pythonUniRawStringendifif exists("python_highlight_doctests") && python_highlight_doctests != 0" DocTestssyn region pythonDocTest start="^\s*>>>" end=+'''+he=s-1 end="^\s*$" containedsyn region pythonDocTest2 start="^\s*>>>" end=+"""+he=s-1 end="^\s*$" containedendif" Numbers (ints, longs, floats, complex)syn match pythonHexError "\<0[xX]\x*[g-zG-Z]\x*[lL]\=\>" displaysyn match pythonHexNumber "\<0[xX]\x\+[lL]\=\>" displaysyn match pythonOctNumber "\<0[oO]\o\+[lL]\=\>" displaysyn match pythonBinNumber "\<0[bB][01]\+[lL]\=\>" displaysyn match pythonNumber "\<\d\+[lLjJ]\=\>" displaysyn match pythonFloat "\.\d\+\([eE][+-]\=\d\+\)\=[jJ]\=\>" displaysyn match pythonFloat "\<\d\+[eE][+-]\=\d\+[jJ]\=\>" displaysyn match pythonFloat "\<\d\+\.\d*\([eE][+-]\=\d\+\)\=[jJ]\=" displaysyn match pythonOctError "\<0[oO]\=\o*[8-9]\d*[lL]\=\>" displaysyn match pythonBinError "\<0[bB][01]*[2-9]\d*[lL]\=\>" displayif exists("python_highlight_builtin_objs") && python_highlight_builtin_objs != 0" Builtin objects and typessyn keyword pythonBuiltinObj True False Ellipsis None NotImplementedsyn keyword pythonBuiltinObj __debug__ __doc__ __file__ __name__ __package__endifif exists("python_highlight_builtin_funcs") && python_highlight_builtin_funcs != 0" Builtin functionssyn keyword pythonBuiltinFunc __import__ abs all any applysyn keyword pythonBuiltinFunc basestring bin bool buffer bytearray bytes callablesyn keyword pythonBuiltinFunc chr classmethod cmp coerce compile complexsyn keyword pythonBuiltinFunc delattr dict dir divmod enumerate evalsyn keyword pythonBuiltinFunc execfile file filter float format frozenset getattrsyn keyword pythonBuiltinFunc globals hasattr hash help hex idsyn keyword pythonBuiltinFunc input int intern isinstancesyn keyword pythonBuiltinFunc issubclass iter len list locals long map maxsyn keyword pythonBuiltinFunc min next object oct open ordsyn keyword pythonBuiltinFunc pow property rangesyn keyword pythonBuiltinFunc raw_input reduce reload reprsyn keyword pythonBuiltinFunc reversed round set setattrsyn keyword pythonBuiltinFunc slice sorted staticmethod str sum super tuplesyn keyword pythonBuiltinFunc type unichr unicode vars xrange zipif exists("python_print_as_function") && python_print_as_function != 0syn keyword pythonBuiltinFunc printendifendifif exists("python_highlight_exceptions") && python_highlight_exceptions != 0" Builtin exceptions and warningssyn keyword pythonExClass BaseExceptionsyn keyword pythonExClass Exception StandardError ArithmeticErrorsyn keyword pythonExClass LookupError EnvironmentErrorsyn keyword pythonExClass AssertionError AttributeError BufferError EOFErrorsyn keyword pythonExClass FloatingPointError GeneratorExit IOErrorsyn keyword pythonExClass ImportError IndexError KeyErrorsyn keyword pythonExClass KeyboardInterrupt MemoryError NameErrorsyn keyword pythonExClass NotImplementedError OSError OverflowErrorsyn keyword pythonExClass ReferenceError RuntimeError StopIterationsyn keyword pythonExClass SyntaxError IndentationError TabErrorsyn keyword pythonExClass SystemError SystemExit TypeErrorsyn keyword pythonExClass UnboundLocalError UnicodeErrorsyn keyword pythonExClass UnicodeEncodeError UnicodeDecodeErrorsyn keyword pythonExClass UnicodeTranslateError ValueError VMSErrorsyn keyword pythonExClass WindowsError ZeroDivisionErrorsyn keyword pythonExClass Warning UserWarning BytesWarning DeprecationWarningsyn keyword pythonExClass PendingDepricationWarning SyntaxWarningsyn keyword pythonExClass RuntimeWarning FutureWarningsyn keyword pythonExClass ImportWarning UnicodeWarningendifif exists("python_slow_sync") && python_slow_sync != 0syn sync minlines=2000else" This is fast but code inside triple quoted strings screws it up. It" is impossible to fix because the only way to know if you are inside a" triple quoted string is to start from the beginning of the file.syn sync match pythonSync grouphere NONE "):$"syn sync maxlines=200endifif version >= 508 || !exists("did_python_syn_inits")if version <= 508let did_python_syn_inits = 1command -nargs=+ HiLink hi link <args>elsecommand -nargs=+ HiLink hi def link <args>endifHiLink pythonStatement StatementHiLink pythonPreCondit StatementHiLink pythonFunction FunctionHiLink pythonConditional ConditionalHiLink pythonRepeat RepeatHiLink pythonException ExceptionHiLink pythonOperator OperatorHiLink pythonDecorator DefineHiLink pythonDottedName FunctionHiLink pythonDot NormalHiLink pythonComment CommentHiLink pythonCoding SpecialHiLink pythonRun SpecialHiLink pythonTodo TodoHiLink pythonError ErrorHiLink pythonIndentError ErrorHiLink pythonSpaceError ErrorHiLink pythonString StringHiLink pythonUniString StringHiLink pythonRawString StringHiLink pythonUniRawString StringHiLink pythonEscape SpecialHiLink pythonEscapeError ErrorHiLink pythonUniEscape SpecialHiLink pythonUniEscapeError ErrorHiLink pythonUniRawEscape SpecialHiLink pythonUniRawEscapeError ErrorHiLink pythonStrFormatting SpecialHiLink pythonStrFormat SpecialHiLink pythonStrTemplate SpecialHiLink pythonDocTest SpecialHiLink pythonDocTest2 SpecialHiLink pythonNumber NumberHiLink pythonHexNumber NumberHiLink pythonOctNumber NumberHiLink pythonBinNumber NumberHiLink pythonFloat FloatHiLink pythonOctError ErrorHiLink pythonHexError ErrorHiLink pythonBinError ErrorHiLink pythonBuiltinObj StructureHiLink pythonBuiltinFunc FunctionHiLink pythonExClass Structuredelcommand HiLinkendiflet b:current_syntax = "python"
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。