On 10/06/09 13:02, Jeri Raye wrote:
>
> Hi,
>
> I'm trying to create syntax file and fail into giving numbers a certain color.
> I want to give a color to
> - binary numbers
> - decimal numbers
> - hexadecimal number
>
> In my syntax the following applies
> binary numbers start with the prefix % .
> ie: %10101010
> %1001
> %1
>
> decimal numbers start with no prefix
> ie: 00
> 55
> 7890
>
> hexadecimal numbers start with the prefix $
> ie: $ABCD
> $00AA
> $BB55
> $10
>
> How do I give this up to the syn match statement?
> What must be in the '<what to put here>' below?
>
> "define matching critera for specific number
> syn match BinaryNumber "<what to put here>"
> syn match DecimalNumber "<what to put here>"
> syn match HexNumber "<what to put here>"
>
> " group different numbers to one label MyNumber
> hi def link BinaryNumber MyNumber
> hi def link DecimalNumber MyNumber
> hi def link HexNumber MyNumber
>
> " link MyNumber to standard syn groups so the 'colorschemes' work:
> hi def link MyNumber number
>
> Rgds,
> Jeri
I haven't seen the other replies yet, but I would say
binary: /%[01]\+\>/
decimal: /\<\d\+\>/
hex: /\$\x\+\>/
(untested). All this assumes 'magic' on, which is the Vim default.
Explanation (see /h ordinary-atom etc.)
/.../ (or anything) pattern boundary
% matches itself
[01] matches 0 or 1
\+ repeats the preceding one or more times, greedily
\> end of word
\< start of word
\d digit 0-9
\x hex digit 0-9A-Fa-f
Best regards,
Tony.
--
Fashion is a form of ugliness so intolerable that we have to alter it
every six months.
-- Oscar Wilde
--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---