@@ -133,7 +133,6 @@ syn match pythonDot '\.' display containedin=pythonDottedName
133
133
"
134
134
" Comments
135
135
"
136
-
137
136
syn match pythonComment ' #.*$' display contains =pythonTodo,@Spell
138
137
if ! s: Enabled (' g:python_highlight_file_headers_as_comments' )
139
138
syn match pythonRun ' \% ^#!.*$'
@@ -193,6 +192,7 @@ syn match pythonUniEscapeError '\\U\x\{,7}\X' display contained
193
192
syn match pythonUniEscape ' \\ N{[A-Z ]\+ }' display contained
194
193
syn match pythonUniEscapeError ' \\ N{[^A-Z ]\+ }' display contained
195
194
195
+
196
196
if s: Python2Syntax ()
197
197
" Python 2 Unicode strings
198
198
syn region pythonUniString start =+ [uU]'+ skip =+ \\\\\|\\ '\|\\ $+ excludenl end =+ '+ end =+ $+ keepend contains =pythonBytesEscape,pythonBytesEscapeError,pythonUniEscape,pythonUniEscapeError,@Spell
@@ -203,15 +203,16 @@ else
203
203
" Python 3 strings
204
204
syn region pythonString start =+ '+ skip =+ \\\\\|\\ '\|\\ $+ excludenl end =+ '+ end =+ $+ keepend contains =pythonBytesEscape,pythonBytesEscapeError,pythonUniEscape,pythonUniEscapeError,@Spell
205
205
syn region pythonString start =+ "+ skip =+ \\\\\|\\ "\|\\ $+ excludenl end =+ "+ end =+ $+ keepend contains =pythonBytesEscape,pythonBytesEscapeError,pythonUniEscape,pythonUniEscapeError,@Spell
206
- syn region pythonString start =+ '''+ skip =+ \\ '+ end =+ '''+ keepend contains =pythonBytesEscape,pythonBytesEscapeError,pythonUniEscape,pythonUniEscapeError,pythonDocTest,pythonSpaceError,@Spell
207
- syn region pythonString start =+ """+ skip =+ \\ "+ end =+ """+ keepend contains =pythonBytesEscape,pythonBytesEscapeError,pythonUniEscape,pythonUniEscapeError,pythonDocTest2,pythonSpaceError,@Spell
206
+ syn region pythonMultiString start =+ '''+ skip =+ \\ '+ end =+ '''+ keepend contains =pythonBytesEscape,pythonBytesEscapeError,pythonUniEscape,pythonUniEscapeError,pythonDocTest,pythonSpaceError,@Spell
207
+ syn region pythonMultiString start =+ """+ skip =+ \\ "+ end =+ """+ keepend contains =pythonBytesEscape,pythonBytesEscapeError,pythonUniEscape,pythonUniEscapeError,pythonDocTest2,pythonSpaceError,@Spell
208
208
209
209
syn region pythonFString start =+ [fF]'+ skip =+ \\\\\|\\ '\|\\ $+ excludenl end =+ '+ end =+ $+ keepend contains =pythonBytesEscape,pythonBytesEscapeError,pythonUniEscape,pythonUniEscapeError,@Spell
210
210
syn region pythonFString start =+ [fF]"+ skip =+ \\\\\|\\ "\|\\ $+ excludenl end =+ "+ end =+ $+ keepend contains =pythonBytesEscape,pythonBytesEscapeError,pythonUniEscape,pythonUniEscapeError,@Spell
211
211
syn region pythonFString start =+ [fF]'''+ skip =+ \\ '+ end =+ '''+ keepend contains =pythonBytesEscape,pythonBytesEscapeError,pythonUniEscape,pythonUniEscapeError,pythonDocTest,pythonSpaceError,@Spell
212
212
syn region pythonFString start =+ [fF]"""+ skip =+ \\ "+ end =+ """+ keepend contains =pythonBytesEscape,pythonBytesEscapeError,pythonUniEscape,pythonUniEscapeError,pythonDocTest2,pythonSpaceError,@Spell
213
213
endif
214
214
215
+
215
216
if s: Python2Syntax ()
216
217
" Python 2 Unicode raw strings
217
218
syn region pythonUniRawString start =+ [uU][rR]'+ skip =+ \\\\\|\\ '\|\\ $+ excludenl end =+ '+ end =+ $+ keepend contains =pythonRawEscape,pythonUniRawEscape,pythonUniRawEscapeError,@Spell
@@ -290,6 +291,17 @@ if s:Enabled('g:python_highlight_doctests')
290
291
syn region pythonDocTest2 start =' ^\s *>>>' skip =+ \\ "+ end =+ """+ he =s - 1 end =' ^\s *$' contained
291
292
endif
292
293
294
+ " Docstrings
295
+ syn match pythonColon ' :' nextgroup =pythonDocString skipempty
296
+ syn match pythonStartFile + \% ^+ nextgroup =pythonDocString skipempty
297
+ syn region pythonDocString start =+ ^\s *'''+ skip =+ \\ '+ end =+ '''+ keepend contains =pythonBytesEscape,pythonBytesEscapeError,pythonUniEscape,pythonUniEscapeError,pythonDocTest,pythonSpaceError,@Spell
298
+ syn region pythonDocString start =+ ^\s *"""+ skip =+ \\ "+ end =+ """+ keepend contains =pythonBytesEscape,pythonBytesEscapeError,pythonUniEscape,pythonUniEscapeError,pythonDocTest2,pythonSpaceError,@Spell
299
+ syn region pythonMultiString start =+ ^\s *'''+ skip =+ \\ '+ end =+ '''+ keepend contains =pythonBytesEscape,pythonBytesEscapeError,pythonUniEscape,pythonUniEscapeError,pythonDocTest,pythonSpaceError,@Spell
300
+ syn region pythonMultiString start =+ ^\s *"""+ skip =+ \\ "+ end =+ """+ keepend contains =pythonBytesEscape,pythonBytesEscapeError,pythonUniEscape,pythonUniEscapeError,pythonDocTest2,pythonSpaceError,@Spell
301
+ syn region pythonDocString start =+ \% ^\s *'''+ skip =+ \\ '+ end =+ '''+ keepend contains =pythonBytesEscape,pythonBytesEscapeError,pythonUniEscape,pythonUniEscapeError,pythonDocTest,pythonSpaceError,@Spell
302
+ syn region pythonDocString start =+ \% ^\s *"""+ skip =+ \\ "+ end =+ """+ keepend contains =pythonBytesEscape,pythonBytesEscapeError,pythonUniEscape,pythonUniEscapeError,pythonDocTest2,pythonSpaceError,@Spell
303
+
304
+
293
305
"
294
306
" Numbers (ints, longs, floats, complex)
295
307
"
@@ -479,6 +491,9 @@ if v:version >= 508 || !exists('did_python_syn_inits')
479
491
HiLink pythonStrFormat Special
480
492
HiLink pythonStrTemplate Special
481
493
494
+ HiLink pythonMultiString String
495
+ HiLink pythonDocString Comment
496
+
482
497
HiLink pythonDocTest Special
483
498
HiLink pythonDocTest2 Special
484
499
0 commit comments