vim syntax 语法 插件 verilog begin end 匹配

空扰寡人 提交于 2019-12-16 18:03:01

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

  真心方便好用!!!

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!