vimsystem-verilogvim-syntax-highlighting

gvim Systemverilog syntax matching :is there way to match `ifdef `ifndef `else and `endif


I have used standard SystemVerilog syntax packages but not able to match(with % move the cursor between) these strings. This is in the context of matchit function in Vim(https://www.vim.org/scripts/script.php?script_id=39). The problem seems to be with backtick.

I tried:

\u0060

and

`ifdef\>|`ifndef\>:`endif\>,

but it does not work.


Solution

  • I'm assuming you have a file that looks like this:

    stuff
    `ifdef
        some code
    `endif
    stuff
    

    With the cursor on `ifdef (or `ifndef), you want to jump to `endif with % then back to `ifdef if you press % again. I'm also assuming you're using the matchit plugin.

    Solution:

    :let b:match_words='`ifdef\>\|`ifndef\>:`endif\>'
    

    Notice that the | has to be escaped with a backslash. Also, you need quotation marks '. So the backticks were not the problem.