# vim语法高亮插件编写
编写vim语法高亮插件很简单,只需要编写两个文件.vim放到vim的
安装目录下的目录就可以了。
## 输出
-----------------------------
- syntax 目录,语法高亮规则,eg. bhl.vim
- ftdetect 目录,检测文件类型自动加载语法高亮规则,eg bhl.vim
## 备注
-----------------------------
-上面两个文件编写好后,放到对应目录下即可。
- .hbl 直接使用语法规则
- 直接原始抓包文件,手工指定文件类型 :set filetype=bhl
## 语法高亮插件 bhl.vim
-----------------------------
```
" Vim syntax file
" filetype: bhl
" Language: BusHoundLog
" Maintainer: lixu <lixugood@126.com>
" Last change: 2017 Jun 01
"
" Language Information
"
" BusHound 抓包日志
" ic卡抓包指令分析,可以高亮显示指令
"
if version < 600
syntax clear
elseif exists("b:current_syntax")
finish
endif
syn keyword BHout OUT
syn keyword BHin IN
"syn match BHout "^ d+.?d?s+OUTs+.*"
"syn match BHin "^ d+.?d?s+INs+.*"
syn match BHok "90s+00"
syn match BHfind "(ffs+04s+01)|(ffs+ca)"
"syn match BHslct "00s+a4s+0[04]"
syn match BHread "(ff|00)s+b[02]"
syn match BHupdt "(ff|0[04])s+d[6c]"
syn match BHauth "ffs+88"
"--------------修改----------------- lixu
"--------------用户卡指令
syn match B_Crd_CPU "00s+20"
syn match B_Crd_CPU "00s+82"
syn match B_Crd_CPU "00s+84"
syn match B_Crd_CPU "00s+88"
syn match B_Crd_CPU "00s+a4"
syn match B_Crd_CPU "00s+20"
syn match B_Crd_CPU "00s+82"
syn match B_Crd_CPU "00s+84"
syn match B_Crd_CPU "00s+88"
syn match B_Crd_CPU "00s+a4"
syn match B_Crd_CPU "00s+b0"
syn match B_Crd_CPU "00s+b2"
syn match B_Crd_CPU "00s+c0"
syn match B_Crd_CPU "00s+d6"
syn match B_Crd_CPU "04s+d6"
syn match B_Crd_CPU "00s+d0"
syn match B_Crd_CPU "04s+d0"
syn match B_Crd_CPU "00s+dc"
syn match B_Crd_CPU "04s+dc"
syn match B_Crd_CPU "00s+d2"
syn match B_Crd_CPU "04s+d2"
syn match B_Crd_CPU "04s+d0"
syn match B_Crd_CPU "84s+16"
syn match B_Crd_CPU "84s+18"
syn match B_Crd_CPU "84s+1e"
syn match B_Crd_CPU "80s+24"
syn match B_Crd_CPU "84s+24"
syn match B_Crd_CPU "80s+2c"
syn match B_Crd_CPU "80s+50"
syn match B_Crd_CPU "80s+52"
syn match B_Crd_CPU "80s+54"
syn match B_Crd_CPU "80s+58"
syn match B_Crd_CPU "80s+5a"
syn match B_Crd_CPU "80s+5c"
syn match B_Crd_CPU "80s+5e"
syn match B_Crd_CPU "80s+0e"
syn match B_Crd_CPU "80s+30"
syn match B_Crd_CPU "80s+32"
syn match B_Crd_CPU "80s+d4"
syn match B_Crd_CPU "84s+d4"
syn match B_Crd_CPU "80s+e0"
"--------------SAM卡指令
syn match B_Crd_SAM "80s+70"
syn match B_Crd_SAM "80s+72"
syn match B_Crd_SAM "80s+fa"
syn match B_Crd_SAM "80s+1c"
syn match B_Crd_SAM "80s+1a"
"-------------错误信息
syn match B_Error "65s+00"
syn match B_Error "67s+00"
syn match B_Error "68s+82"
syn match B_Error "69s+01"
syn match B_Error "69s+81"
syn match B_Error "69s+82"
syn match B_Error "69s+83"
syn match B_Error "69s+84"
syn match B_Error "69s+85"
syn match B_Error "69s+86"
syn match B_Error "69s+87"
syn match B_Error "69s+88"
syn match B_Error "6as+80"
syn match B_Error "6as+81"
syn match B_Error "6as+82"
syn match B_Error "6as+83"
syn match B_Error "6as+84"
syn match B_Error "6as+85"
syn match B_Error "6as+86"
syn match B_Error "6as+88"
"syn match B_Error "6bs+00"
syn match B_Error "6es+00"
syn match B_Error "6fs+00"
syn match B_Error "6as+86"
syn match B_Error "93s+02"
syn match B_Error "93s+03"
syn match B_Error "94s+01"
syn match B_Error "94s+02"
syn match B_Error "94s+03"
syn match B_Error "94s+06"
syn match B_Error "63s+cd"
"--------------读卡控制指令
syn match BCrd "00s+62"
syn match BCrd "00s+63"
syn match BCrd "00s+6f"
syn match BCrd "00s+6f"
syn match B_Drd "00s+50"
syn match B_Drd "ffs+01"
syn match B_Drd "ffs+02"
syn match B_Drd "ffs+03"
syn match B_Drd "ffs+04"
syn match B_Drd "ffs+05"
syn match B_Drd "ffs+06"
syn match B_Drd "ffs+8a"
syn match B_Drd "ffs+8b"
syn match B_Drd "ffs+8c"
"----------------Mifare卡
syn match B_Drd "ffs+82"
syn match B_Drd "ffs+88"
syn match B_Drd "ffs+b0"
syn match B_Drd "ffs+d6"
syn match B_Drd "ffs+ca"
syn match B_Drd "ffs+cb"
syn match B_Drd "ffs+cc"
syn match B_Drd "ffs+cd"
"--------------配色
hi BCrd guifg=gray
hi BHout guifg=yellow
hi BHin guifg=blue
hi BHfind guifg=DarkOliveGreen1 guibg=grey15
hi BHok guifg=grey15 guibg=green
hi link BHfind BHok
hi BHslct guifg=green guibg=blue
hi BHread guifg=purple guibg=grey
hi BHupdt guifg=brown guibg=grey
hi BHauth guifg=magenta guibg=grey
"-------------------配色
hi B_Crd_SAM guifg=grey15 guibg=yellow
hi B_Crd_CPU guifg=grey15 guibg=blue
hi B_Error guifg=grey15 guibg=red
hi B_Drd guifg=lightmagenta
let b:current_syntax = "BusHoundLog"
```
## 文件类型管理 bhl.vim
-----------------------------
```
" bhl filetype file
au BufRead,BufNewFile *.bhl set filetype=bhl
```
[参考](http://www.cnblogs.com/plwang1990/p/4106695.html)