Skip to content

Commit 69f8e12

Browse files
committed
Add new option 'python_highlight_file_headers_as_comments'
The option is disabled by default and when enabled highlight shebang and coding file headers as comments instead of special characters.
1 parent 21a2e84 commit 69f8e12

File tree

3 files changed

+16
-4
lines changed

3 files changed

+16
-4
lines changed

CHANGES.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ Revision 3.3.5 (2013-08-31):
22

33
- Highlight 'import', 'from' and 'as' as include statements.
44
Patch by pydave at GitHub.
5+
- Added new option 'python_highlight_file_headers_as_comments' (disabled by
6+
default) to highlight shebang and coding file headers as comments.
7+
Proposed by pydave at GitHub.
58

69
Revision 3.3.4 (2013-08-11):
710

README.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,8 @@ Options used by the script
117117
Highlight doc-tests
118118
``python_print_as_function``
119119
Highlight ``print`` statement as function for Python 2
120+
``python_highlight_file_headers_as_comments``
121+
Highlight shebang and coding headers as comments
120122
``python_highlight_all``
121123
Enable all the options above. *NOTE: This option don't override any
122124
previously set options*

syntax/python.vim

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,9 @@
7373
" python_highlight_doctests Highlight doc-tests
7474
" python_print_as_function Highlight 'print' statement as
7575
" function for Python 2
76+
" python_highlight_file_headers_as_comments
77+
" Highlight shebang and coding
78+
" headers as comments
7679
"
7780
" python_highlight_all Enable all the options above
7881
" NOTE: This option don't override
@@ -179,8 +182,10 @@ syn match pythonDot "\." display containedin=pythonDottedName
179182
"
180183

181184
syn match pythonComment "#.*$" display contains=pythonTodo,@Spell
182-
syn match pythonRun "\%^#!.*$"
183-
syn match pythonCoding "\%^.*\%(\n.*\)\?#.*coding[:=]\s*[0-9A-Za-z-_.]\+.*$"
185+
if !s:Enabled("g:python_highlight_file_headers_as_comments")
186+
syn match pythonRun "\%^#!.*$"
187+
syn match pythonCoding "\%^.*\%(\n.*\)\?#.*coding[:=]\s*[0-9A-Za-z-_.]\+.*$"
188+
endif
184189
syn keyword pythonTodo TODO FIXME XXX contained
185190

186191
"
@@ -482,8 +487,10 @@ if version >= 508 || !exists("did_python_syn_inits")
482487
HiLink pythonDot Normal
483488

484489
HiLink pythonComment Comment
485-
HiLink pythonCoding Special
486-
HiLink pythonRun Special
490+
if !s:Enabled("g:python_highlight_file_headers_as_comments")
491+
HiLink pythonCoding Special
492+
HiLink pythonRun Special
493+
endif
487494
HiLink pythonTodo Todo
488495

489496
HiLink pythonError Error

0 commit comments

Comments
 (0)