• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1" Auto-generated Vim syntax file for Python (trunk: r80490).
2"
3" To use: copy or symlink to ~/.vim/syntax/python.vim
4
5
6if exists("b:current_syntax")
7  finish
8endif
9
10if exists("python_highlight_all")
11  let python_highlight_numbers = 1
12  let python_highlight_builtins = 1
13  let python_highlight_exceptions = 1
14  let python_highlight_space_errors = 1
15endif
16
17syn keyword pythonStatement    as assert break continue del except exec finally
18syn keyword pythonStatement    global lambda pass print raise return try with
19syn keyword pythonStatement    yield
20
21syn keyword pythonStatement    def class nextgroup=pythonFunction skipwhite
22
23syn match pythonFunction    "[a-zA-Z_][a-zA-Z0-9_]*" contained
24
25syn keyword pythonRepeat    for while
26
27syn keyword pythonConditional    if elif else
28
29syn keyword pythonOperator    and in is not or
30
31syn keyword pythonPreCondit    import from
32
33syn match pythonComment    "#.*$" contains=pythonTodo
34
35syn keyword pythonTodo    TODO FIXME XXX contained
36
37syn region pythonString    matchgroup=Normal start=+[uU]\='+ end=+'+ skip=+\\\\\|\\'+ contains=pythonEscape
38syn region pythonString    matchgroup=Normal start=+[uU]\="+ end=+"+ skip=+\\\\\|\\"+ contains=pythonEscape
39syn region pythonString    matchgroup=Normal start=+[uU]\="""+ end=+"""+  contains=pythonEscape
40syn region pythonString    matchgroup=Normal start=+[uU]\='''+ end=+'''+  contains=pythonEscape
41syn region pythonString    matchgroup=Normal start=+[uU]\=[rR]'+ end=+'+ skip=+\\\\\|\\'+
42syn region pythonString    matchgroup=Normal start=+[uU]\=[rR]"+ end=+"+ skip=+\\\\\|\\"+
43syn region pythonString    matchgroup=Normal start=+[uU]\=[rR]"""+ end=+"""+
44syn region pythonString    matchgroup=Normal start=+[uU]\=[rR]'''+ end=+'''+
45
46syn match pythonEscape    +\\[abfnrtv\'"\\]+ contained
47syn match pythonEscape    "\\\o\{1,3}" contained
48syn match pythonEscape    "\\x\x\{2}" contained
49syn match pythonEscape    "\(\\u\x\{4}\|\\U\x\{8}\)" contained
50
51syn match pythonEscape    "\\$"
52
53
54if exists("python_highlight_numbers")
55  syn match pythonNumber    "\<0x\x\+[Ll]\=\>"
56  syn match pythonNumber    "\<\d\+[LljJ]\=\>"
57  syn match pythonNumber    "\.\d\+\([eE][+-]\=\d\+\)\=[jJ]\=\>"
58  syn match pythonNumber    "\<\d\+\.\([eE][+-]\=\d\+\)\=[jJ]\=\>"
59  syn match pythonNumber    "\<\d\+\.\d\+\([eE][+-]\=\d\+\)\=[jJ]\=\>"
60
61endif
62
63
64if exists("python_highlight_builtins")
65  syn keyword pythonBuiltin    Ellipsis False None NotImplemented True __debug__
66  syn keyword pythonBuiltin    __import__ abs all any apply basestring bin bool
67  syn keyword pythonBuiltin    buffer bytearray bytes callable chr classmethod
68  syn keyword pythonBuiltin    cmp coerce compile complex copyright credits
69  syn keyword pythonBuiltin    delattr dict dir divmod enumerate eval execfile
70  syn keyword pythonBuiltin    exit file filter float format frozenset getattr
71  syn keyword pythonBuiltin    globals hasattr hash help hex id input int intern
72  syn keyword pythonBuiltin    isinstance issubclass iter len license list
73  syn keyword pythonBuiltin    locals long map max memoryview min next object
74  syn keyword pythonBuiltin    oct open ord pow print property quit range
75  syn keyword pythonBuiltin    raw_input reduce reload repr reversed round set
76  syn keyword pythonBuiltin    setattr slice sorted staticmethod str sum super
77  syn keyword pythonBuiltin    tuple type unichr unicode vars xrange zip
78
79endif
80
81
82if exists("python_highlight_exceptions")
83  syn keyword pythonException    ArithmeticError AssertionError AttributeError
84  syn keyword pythonException    BaseException BufferError BytesWarning
85  syn keyword pythonException    DeprecationWarning EOFError EnvironmentError
86  syn keyword pythonException    Exception FloatingPointError FutureWarning
87  syn keyword pythonException    GeneratorExit IOError ImportError ImportWarning
88  syn keyword pythonException    IndentationError IndexError KeyError
89  syn keyword pythonException    KeyboardInterrupt LookupError MemoryError
90  syn keyword pythonException    NameError NotImplementedError OSError
91  syn keyword pythonException    OverflowError PendingDeprecationWarning
92  syn keyword pythonException    ReferenceError RuntimeError RuntimeWarning
93  syn keyword pythonException    StandardError StopIteration SyntaxError
94  syn keyword pythonException    SyntaxWarning SystemError SystemExit TabError
95  syn keyword pythonException    TypeError UnboundLocalError UnicodeDecodeError
96  syn keyword pythonException    UnicodeEncodeError UnicodeError
97  syn keyword pythonException    UnicodeTranslateError UnicodeWarning
98  syn keyword pythonException    UserWarning ValueError Warning
99  syn keyword pythonException    ZeroDivisionError
100
101endif
102
103
104if exists("python_highlight_space_errors")
105  syn match pythonSpaceError    display excludenl "\S\s\+$"ms=s+1
106  syn match pythonSpaceError    display " \+\t"
107  syn match pythonSpaceError    display "\t\+ "
108
109endif
110
111
112  hi def link pythonStatement Statement
113  hi def link pythonStatement Statement
114  hi def link pythonFunction Function
115  hi def link pythonRepeat Repeat
116  hi def link pythonConditional Conditional
117  hi def link pythonOperator Operator
118  hi def link pythonPreCondit PreCondit
119  hi def link pythonComment Comment
120  hi def link pythonTodo Todo
121  hi def link pythonString String
122  hi def link pythonEscape Special
123  hi def link pythonEscape Special
124
125  if exists("python_highlight_numbers")
126    hi def link pythonNumber Number
127  endif
128
129  if exists("python_highlight_builtins")
130    hi def link pythonBuiltin Function
131  endif
132
133  if exists("python_highlight_exceptions")
134    hi def link pythonException Exception
135  endif
136
137  if exists("python_highlight_space_errors")
138    hi def link pythonSpaceError Error
139  endif
140
141
142" Uncomment the 'minlines' statement line and comment out the 'maxlines'
143" statement line; changes behaviour to look at least 2000 lines previously for
144" syntax matches instead of at most 200 lines
145syn sync match pythonSync grouphere NONE "):$"
146syn sync maxlines=200
147"syn sync minlines=2000
148
149let b:current_syntax = "python"
150