11" Vim syntax file
22" Language: Python
33" Maintainer: Zvezdan Petkovic <[email protected] >4- " Last Change: 2025 Jul 17
4+ " Last Change: 2025 Jul 26
55" Credits: Neil Schemenauer <[email protected] >66" Dmitry Vasiliev
77" Rob B
9797syn keyword pythonStatement False None True
9898syn keyword pythonStatement as assert break continue del global
9999syn keyword pythonStatement lambda nonlocal pass return with yield
100- syn keyword pythonStatement class def nextgroup =pythonFunction skipwhite
100+ syn keyword pythonStatement class nextgroup =pythonClass skipwhite
101+ syn keyword pythonStatement def nextgroup =pythonFunction skipwhite
101102syn keyword pythonConditional elif else if
102103syn keyword pythonRepeat for while
103104syn keyword pythonOperator and in is not or
@@ -123,20 +124,21 @@ syn match pythonDecoratorName "@\s*\h\%(\w\|\.\)*" display contains=pythonDeco
123124" Single line multiplication.
124125syn match pythonMatrixMultiply
125126 \ " \% (\w\| [])]\)\s *@"
126- \ contains= ALLBUT ,pythonDecoratorName,pythonDecorator,pythonFunction,pythonDoctestValue
127+ \ contains= ALLBUT ,pythonDecoratorName,pythonDecorator,pythonClass, pythonFunction,pythonDoctestValue
127128 \ transparent
128129" Multiplication continued on the next line after backslash.
129130syn match pythonMatrixMultiply
130131 \ " [^\\ ]\\ \s *\n \% (\s *\.\.\.\s\)\=\s\+ @"
131- \ contains= ALLBUT ,pythonDecoratorName,pythonDecorator,pythonFunction,pythonDoctestValue
132+ \ contains= ALLBUT ,pythonDecoratorName,pythonDecorator,pythonClass, pythonFunction,pythonDoctestValue
132133 \ transparent
133134" Multiplication in a parenthesized expression over multiple lines with @ at
134135" the start of each continued line; very similar to decorators and complex.
135136syn match pythonMatrixMultiply
136137 \ " ^\s *\% (\% (>>>\|\.\.\.\)\s\+\)\=\z s\% (\h\|\% (\h\| [[(]\) .\{ -}\% (\w\| [])]\)\)\s *\n \% (\s *\.\.\.\s\)\=\s\+ @\% (.\{ -}\n \% (\s *\.\.\.\s\)\=\s\+ @\) *"
137- \ contains= ALLBUT ,pythonDecoratorName,pythonDecorator,pythonFunction,pythonDoctestValue
138+ \ contains= ALLBUT ,pythonDecoratorName,pythonDecorator,pythonClass, pythonFunction,pythonDoctestValue
138139 \ transparent
139140
141+ syn match pythonClass " \h\w *" display contained
140142syn match pythonFunction " \h\w *" display contained
141143
142144syn match pythonComment " #.*$" contains =pythonTodo,@Spell
@@ -279,7 +281,7 @@ if !exists("python_no_builtin_highlight")
279281 syn keyword pythonBuiltin tuple type vars zip __import__
280282 " avoid highlighting attributes as builtins
281283 syn match pythonAttribute / \.\h\w */ hs =s + 1
282- \ contains= ALLBUT ,pythonBuiltin,pythonFunction,pythonAsync
284+ \ contains= ALLBUT ,pythonBuiltin,pythonClass, pythonFunction,pythonAsync
283285 \ transparent
284286endif
285287
@@ -336,7 +338,7 @@ if !exists("python_no_doctest_highlight")
336338 if ! exists (" python_no_doctest_code_highlight" )
337339 syn region pythonDoctest
338340 \ start = " ^\s *>>>\s " end = " ^\s *$"
339- \ contained contains= ALLBUT ,pythonDoctest,pythonFunction,@S pell
341+ \ contained contains= ALLBUT ,pythonDoctest,pythonClass, pythonFunction,@S pell
340342 syn region pythonDoctestValue
341343 \ start = + ^\s * \% (>>>\s\|\.\.\.\s\| " " " \| '''\)\@ !\S\+ + end=" $ "
342344 \ contained
@@ -360,6 +362,7 @@ hi def link pythonInclude Include
360362hi def link pythonAsync Statement
361363hi def link pythonDecorator Define
362364hi def link pythonDecoratorName Function
365+ hi def link pythonClass Structure
363366hi def link pythonFunction Function
364367hi def link pythonComment Comment
365368hi def link pythonTodo Todo
0 commit comments