Search code examples
vimcommentsverilog

Verilog Mode - how to turn off colors for /* */ comments?


I am using vim to edit a customer's Verilog libmap file and the syntax highlighting for multi-line comments is causing very odd color enabling/disabling. The problem is that the libmap is searching large numbers of files in multiple directories so there are lots of dir1/dir2/*/*/*/*/*.v searches and each /* turns on comment colors and each corresponding */ turns it back off, so with all of the libmap wildcard directories the comments are turning on and off and sometimes remain off on the next active line of code. I just want to know how to define (undefine) comment colors in Verilog mode. I will leave colors on for single line comments (// comment) but disable them for multi-line comments (/* */), which I rarely use, or perhaps change multi-line comments to require a space after /*. I have snooped around the syntax definition file but cannot spot how the comments are being handled. I am hoping this is relatively easy to do. Regards - Cliff Cummings


Solution

  • Obviously, you don't want to "change colors", but to "change syntax". As patching standard runtime file is not an option, make use of :h after-directory.

    ~/.vim/after/syntax/verilog.vim

    syntax clear verilogComment
    " restore //comment
    syntax match verilogComment "//.*" contains=verilogTodo,@Spell
    " no /*comment*/
    "syntax region verilogComment start="/\*" end="\*/" contains=verilogTodo,@Spell