Commit: runtime(python): highlight bytes in python

0 views
Skip to first unread message

Christian Brabandt

unread,
Jul 14, 2025, 4:45:14 PM7/14/25
to vim...@googlegroups.com
runtime(python): highlight bytes in python

Commit: https://github.com/vim/vim/commit/a24f5be86d895981cb84266f98bae9f14407264b
Author: Rob B <git...@0x7e.net>
Date: Mon Jul 14 22:30:59 2025 +0200

runtime(python): highlight bytes in python

- Highlight bytes literals
- Do not highlight Unicode escape sequences in bytes literals

fixes: #14033
fixes: #17726
closes: #17728

Signed-off-by: Rob B <git...@0x7e.net>
Signed-off-by: Christian Brabandt <c...@256bit.org>

diff --git a/runtime/syntax/python.vim b/runtime/syntax/python.vim
index 68036f590..759af2d4f 100644
--- a/runtime/syntax/python.vim
+++ b/runtime/syntax/python.vim
@@ -1,9 +1,10 @@
" Vim syntax file
" Language: Python
" Maintainer: Zvezdan Petkovic <zpet...@acm.org>
-" Last Change: 2023 Feb 28
+" Last Change: 2025 Jul 14
" Credits: Neil Schemenauer <n...@python.ca>
" Dmitry Vasiliev
+" Rob B
"
" This version is a major rewrite by Zvezdan Petkovic.
"
@@ -144,24 +145,48 @@ syn keyword pythonTodo FIXME NOTE NOTES TODO XXX contained
" Triple-quoted strings can contain doctests.
syn region pythonString matchgroup=pythonQuotes
\ start=+[uU]\=\z(['"]\)+ end="\z1" skip="\\\|\\z1"
- \ contains=pythonEscape,@Spell
+ \ contains=pythonEscape,pythonUnicodeEscape,@Spell
syn region pythonString matchgroup=pythonTripleQuotes
\ start=+[uU]\=\z('''\|"""\)+ end="\z1" keepend
- \ contains=pythonEscape,pythonSpaceError,pythonDoctest,@Spell
+ \ contains=pythonEscape,pythonUnicodeEscape,pythonSpaceError,pythonDoctest,@Spell
syn region pythonRawString matchgroup=pythonQuotes
- \ start=+[uU]\=[rR]\z(['"]\)+ end="\z1" skip="\\\|\\z1"
+ \ start=+[rR]\z(['"]\)+ end="\z1" skip="\\\|\\z1"
\ contains=@Spell
syn region pythonRawString matchgroup=pythonTripleQuotes
- \ start=+[uU]\=[rR]\z('''\|"""\)+ end="\z1" keepend
+ \ start=+[rR]\z('''\|"""\)+ end="\z1" keepend
\ contains=pythonSpaceError,pythonDoctest,@Spell

+" Bytes
+syn region pythonBytes
+ \ matchgroup=pythonQuotes
+ \ start=+
Reply all
Reply to author
Forward
0 new messages