简体   繁体   English

Vim regex:二进制数

[英]Vim regex : Binary number

I want to match binary numbers in vim, 我想在vim中匹配二进制数,

such as 0b101 , 0b111010 , or 0b110 in 0b110; 0b1010b111010,0b1100b110;

but not 0b1013 , or 0b10 in 0b10c 但不0b1013,0b10c 0b10

I am trying to do it like this in vim script: 我正在尝试在vim脚本中这样做:

syntax match Number "\v\W0[bB][01][01]*"

However, it also matches 0b101 in 0b101fa . 但是,它也匹配0b101fa中的0b101

Is there any way to match them correctly? 有什么办法可以正确匹配它们?

Thanks 谢谢

You can use these commands : 您可以使用以下命令:

:syntax match BinaryNb /\v<0[Bb][01]+>/
:highlight link BinaryNb Error

Demo : 演示

在此处输入图片说明

Hexadecimal must match byte unit. 十六进制必须匹配字节单元。 Refer to following image. 请参考下图。

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM