vim syntax 语法 插件 verilog begin end 匹配

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

  真心方便好用!!!

  • 3
    点赞
  • 14
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
vim是一款强大的文本编辑器,支持丰富的语法高亮功能。在使用vim编辑器进行Verilog代码编写时,可以通过一些设置实现Verilog语法的高亮显示。 首先,确保在vim中已经安装了verilog插件。可以通过vim插件管理器(如Vundle或者Pathogen)进行安装,或者手动将相关插件文件放置在vim插件目录中。 安装完verilog插件后,需要设置vim的配置文件以启用语法高亮功能。找到并打开vim配置文件(通常是~/.vimrc),添加如下内容: ```vim syntax enable " 启用语法高亮 filetype plugin indent on " 启用自动识别文件类型和缩进功能 ``` 保存并退出配置文件。 之后,在vim中打开一个Verilog文件,就可以看到代码根据语法高亮显示了。不同的代码元素,如关键字、变量、数字、注释等,会以不同的颜色突出显示,以帮助编程者更容易地阅读和调整代码。 此外,还可以根据个人的喜好和需求,自定义vimVerilog语法高亮的颜色。在vim配置文件中,找到或添加如下内容: ```vim highlight VerilogKeyword ctermfg=green " 定义关键字颜色为绿色 highlight VerilogIdentifier ctermfg=blue " 定义变量标识符颜色为蓝色 ``` 以上是一个简单的设置示例,可以根据自己的需求进行进一步的颜色定义和个性化设置。 通过以上步骤,就可以在vim中实现Verilog语法的高亮显示,提高代码编写的效率和准确性。
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值