Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
support underscores in numbers
mostly taken from hdima/python-syntax#60
  • Loading branch information
lilydjwg committed Feb 17, 2017
commit f8d6b63f95b9366322a0b25316e99e6b5931115a
33 changes: 21 additions & 12 deletions syntax/python.vim
Original file line number Diff line number Diff line change
Expand Up @@ -318,28 +318,37 @@ if s:Python2Syntax()

syn match pythonOctError '\<0[oO]\=\o*[8-9]\d*[lL]\=\>' display
syn match pythonBinError '\<0[bB][01]*[2-9]\d*[lL]\=\>' display

syn match pythonFloat '\.\d\+\%([eE][+-]\=\d\+\)\=[jJ]\=\>' display
syn match pythonFloat '\<\d\+[eE][+-]\=\d\+[jJ]\=\>' display
syn match pythonFloat '\<\d\+\.\d*\%([eE][+-]\=\d\+\)\=[jJ]\=' display
else
syn match pythonHexError '\<0[xX]\x*[g-zG-Z]\x*\>' display
syn match pythonOctError '\<0[oO]\=\o*\D\+\d*\>' display
" pythonHexError comes after pythonOctError so that 0xffffl is pythonHexError
syn match pythonHexError '\<0[xX]\x*[g-zG-Z]\x*\>' display
syn match pythonBinError '\<0[bB][01]*\D\+\d*\>' display

syn match pythonHexNumber '\<0[xX]\x\+\>' display
syn match pythonOctNumber '\<0[oO]\o\+\>' display
syn match pythonBinNumber '\<0[bB][01]\+\>' display
syn match pythonHexNumber '\<0[xX][_0-9a-fA-F]*\x\>' display
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove a space here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, it's a tab. Never use tabs.

syn match pythonOctNumber '\<0[oO][_0-7]*\o\>' display
syn match pythonBinNumber '\<0[bB][_01]*[01]\>' display

syn match pythonNumberError '\<\d\+\D\>' display
syn match pythonNumberError '\<0\d\+\>' display
syn match pythonNumberError '\<\d[_0-9]*\D\>' display
syn match pythonNumberError '\<0[_0-9]\+\>' display
syn match pythonNumberError '\<0_x\S*\>' display
syn match pythonNumberError '\<0[bBxXoO][_0-9a-fA-F]*_\>' display
syn match pythonNumberError '\<\d[_0-9]*_\>' display
syn match pythonNumber '\<\d\>' display
syn match pythonNumber '\<[1-9]\d\+\>' display
syn match pythonNumber '\<\d\+[jJ]\>' display
syn match pythonNumber '\<[1-9][_0-9]*\d\>' display
syn match pythonNumber '\<\d[jJ]\>' display
syn match pythonNumber '\<[1-9][_0-9]*\d[jJ]\>' display

syn match pythonOctError '\<0[oO]\=\o*[8-9]\d*\>' display
syn match pythonBinError '\<0[bB][01]*[2-9]\d*\>' display
endif

syn match pythonFloat '\.\d\+\%([eE][+-]\=\d\+\)\=[jJ]\=\>' display
syn match pythonFloat '\<\d\+[eE][+-]\=\d\+[jJ]\=\>' display
syn match pythonFloat '\<\d\+\.\d*\%([eE][+-]\=\d\+\)\=[jJ]\=' display
syn match pythonFloat '\.\d\%([_0-9]*\d\)\=\%([eE][+-]\=\d\%([_0-9]*\d\)\=\)\=[jJ]\=\>' display
syn match pythonFloat '\<\d\%([_0-9]*\d\)\=[eE][+-]\=\d\%([_0-9]*\d\)\=[jJ]\=\>' display
syn match pythonFloat '\<\d\%([_0-9]*\d\)\=\.\d\%([_0-9]*\d\)\=\%([eE][+-]\=\d\%([_0-9]*\d\)\=\)\=[jJ]\=' display
endif

"
" Builtin objects and types
Expand Down