Vim Syntax Plugin for Verilog and SystemVerilog
https://github.com/vhda/verilog_systemverilog.vim
https://stackoverflow.com/questions/27498221/vim-highlight-matching-begin-end
using matchit. This script is part of vim runtime and can easily be loaded by adding the following line to your .vimrc:
runtime macros/matchit.vim
The standard Verilog filetype plugin already includes the matchit configuration you require:
" Let the matchit plugin know what items can be matched.
if exists("loaded_matchit")
let b:match_ignorecase=0
let b:match_words=
\ '\<begin\>:\<end\>,' .
\ '\<case\>\|\<casex\>\|\<casez\>:\<endcase\>,' .
\ '\<module\>:\<endmodule\>,' .
\ '\<if\>:\<else\>,' .
\ '\<function\>:\<endfunction\>,' .
\ '`ifdef\>:`else\>:`endif\>,' .
\ '\<task\>:\<endtask\>,' .
\ '\<specify\>:\<endspecify\>'
endif
This way you can match the begin/end using %
key, as you probably already do for parentheses and such.
https://www.cnblogs.com/air-of-code/p/4733151.html
matchit這個插件,是vim自帶的,但是默認不安裝。在vim中默認可以用%來實現括號之間的跳轉,但是有了這個插件可以設置任意想跳轉的標記。
在linux中敲vi打開一個空白的文件
:help matchit-install
可以看到安裝matchit的步驟
就是在cd.vim文件夾下
mkdir ~/.vim/plugin
cp $VIMRUNTIME/macros/matchit.vim ~/.vim/plugin
mkdir ~/.vim/doc
cp $VIMRUNTIME/macros/matchit.txt ~/.vim/plugin
然後let b:match_words='\<begin\>:\<end\>' 加到.vimrc文件中
這裏還可以根據自己的需要加上module,primitive等需要匹配的字符串。
這樣就OK了,打開任意一個文件用%就可以看到begin end之間的匹配了。
在拷上面兩個文件的時候沒有VIMRUNTIME這個環境變量,在linux中echo一下也是空白,後來在vim中echo纔出來了,這個變量是VIM的安裝路徑。如果在linux中不能用,直接用路徑替換掉這個變量就好啦。
還有一個方法可以替代上面的拷這兩個文件,在.vimrc中加上下面這句話
source $VIMRUNTIME/macros/matchit.vim
或者
runtime macros/matchit.vim
還可以在匹配時設這忽略大小寫敏感,例如如果在.vimrc中有這句話
let b:match_ignorecase = 1
就是忽略大小寫,那樣begin和END也可以匹配,如果要關掉大小寫敏感的話
let b:match_ignorecase = 0
真心方便好用!!!