# vim語法高亮插件編寫html
編寫vim語法高亮插件很簡單,只須要編寫兩個文件.vim放到vim的
安裝目錄下的目錄就能夠了。vim
## 輸出
-----------------------------
- syntax 目錄,語法高亮規則,eg. bhl.vim
- ftdetect 目錄,檢測文件類型自動加載語法高亮規則,eg bhl.vimui
## 備註
-----------------------------
-上面兩個文件編寫好後,放到對應目錄下便可。
- .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卡抓包指令分析,能夠高亮顯示指令
"orm
if version < 600
syntax clear
elseif exists("b:current_syntax")
finish
endifhtm
syn keyword BHout OUT
syn keyword BHin IN
"syn match BHout "^ \d\+.\?\d\?\s\+OUT\s\+.*"
"syn match BHin "^ \d\+.\?\d\?\s\+IN\s\+.*"
syn match BHok "90\s\+00"
syn match BHfind "\(ff\s\+04\s\+01\)\|\(ff\s\+ca\)"
"syn match BHslct "00\s\+a4\s\+0[04]"
syn match BHread "\(ff\|00\)\s\+b[02]"
syn match BHupdt "\(ff\|0[04]\)\s\+d[6c]"
syn match BHauth "ff\s\+88"blog
"--------------修改----------------- lixu
"--------------用戶卡指令
syn match B_Crd_CPU "00\s\+20"
syn match B_Crd_CPU "00\s\+82"
syn match B_Crd_CPU "00\s\+84"
syn match B_Crd_CPU "00\s\+88"
syn match B_Crd_CPU "00\s\+a4"io
syn match B_Crd_CPU "00\s\+20"
syn match B_Crd_CPU "00\s\+82"
syn match B_Crd_CPU "00\s\+84"
syn match B_Crd_CPU "00\s\+88"
syn match B_Crd_CPU "00\s\+a4"ast
syn match B_Crd_CPU "00\s\+b0"
syn match B_Crd_CPU "00\s\+b2"
syn match B_Crd_CPU "00\s\+c0"
syn match B_Crd_CPU "00\s\+d6"
syn match B_Crd_CPU "04\s\+d6"
syn match B_Crd_CPU "00\s\+d0"
syn match B_Crd_CPU "04\s\+d0"
syn match B_Crd_CPU "00\s\+dc"
syn match B_Crd_CPU "04\s\+dc"
syn match B_Crd_CPU "00\s\+d2"
syn match B_Crd_CPU "04\s\+d2"
syn match B_Crd_CPU "04\s\+d0"
syn match B_Crd_CPU "84\s\+16"
syn match B_Crd_CPU "84\s\+18"
syn match B_Crd_CPU "84\s\+1e"
syn match B_Crd_CPU "80\s\+24"
syn match B_Crd_CPU "84\s\+24"
syn match B_Crd_CPU "80\s\+2c"
syn match B_Crd_CPU "80\s\+50"
syn match B_Crd_CPU "80\s\+52"
syn match B_Crd_CPU "80\s\+54"
syn match B_Crd_CPU "80\s\+58"
syn match B_Crd_CPU "80\s\+5a"
syn match B_Crd_CPU "80\s\+5c"
syn match B_Crd_CPU "80\s\+5e"
syn match B_Crd_CPU "80\s\+0e"
syn match B_Crd_CPU "80\s\+30"
syn match B_Crd_CPU "80\s\+32"
syn match B_Crd_CPU "80\s\+d4"
syn match B_Crd_CPU "84\s\+d4"
syn match B_Crd_CPU "80\s\+e0"
"--------------SAM卡指令
syn match B_Crd_SAM "80\s\+70"
syn match B_Crd_SAM "80\s\+72"
syn match B_Crd_SAM "80\s\+fa"
syn match B_Crd_SAM "80\s\+1c"
syn match B_Crd_SAM "80\s\+1a"
"-------------錯誤信息
syn match B_Error "65\s\+00"
syn match B_Error "67\s\+00"
syn match B_Error "68\s\+82"
syn match B_Error "69\s\+01"
syn match B_Error "69\s\+81"
syn match B_Error "69\s\+82"
syn match B_Error "69\s\+83"
syn match B_Error "69\s\+84"
syn match B_Error "69\s\+85"
syn match B_Error "69\s\+86"
syn match B_Error "69\s\+87"
syn match B_Error "69\s\+88"
syn match B_Error "6a\s\+80"
syn match B_Error "6a\s\+81"
syn match B_Error "6a\s\+82"
syn match B_Error "6a\s\+83"
syn match B_Error "6a\s\+84"
syn match B_Error "6a\s\+85"
syn match B_Error "6a\s\+86"
syn match B_Error "6a\s\+88"
"syn match B_Error "6b\s\+00"
syn match B_Error "6e\s\+00"
syn match B_Error "6f\s\+00"
syn match B_Error "6a\s\+86"
syn match B_Error "93\s\+02"
syn match B_Error "93\s\+03"
syn match B_Error "94\s\+01"
syn match B_Error "94\s\+02"
syn match B_Error "94\s\+03"
syn match B_Error "94\s\+06"
syn match B_Error "63\s\+c\d"
"--------------讀卡控制指令
syn match BCrd "00\s\+62"
syn match BCrd "00\s\+63"
syn match BCrd "00\s\+6f"
syn match BCrd "00\s\+6f"
syn match B_Drd "00\s\+50"
syn match B_Drd "ff\s\+01"
syn match B_Drd "ff\s\+02"
syn match B_Drd "ff\s\+03"
syn match B_Drd "ff\s\+04"
syn match B_Drd "ff\s\+05"
syn match B_Drd "ff\s\+06"
syn match B_Drd "ff\s\+8a"
syn match B_Drd "ff\s\+8b"
syn match B_Drd "ff\s\+8c"
"----------------Mifare卡
syn match B_Drd "ff\s\+82"
syn match B_Drd "ff\s\+88"
syn match B_Drd "ff\s\+b0"
syn match B_Drd "ff\s\+d6"
syn match B_Drd "ff\s\+ca"
syn match B_Drd "ff\s\+cb"
syn match B_Drd "ff\s\+cc"
syn match B_Drd "ff\s\+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)