Need a shortcut for finding the end for a particular begin in SystemVerilog syntax.


vim has a matchit package which lets the % key in command mode jump from a begin to the matching end, from a <tag> to the matching </tag>, etc. just as it does by default with matching braces, brackets, parentheses, etc.

To use it, you can enable the matchit package with

:packadd! matchit

Then define the matching words with

:let b:match_words = '\<begin\>:\<end\>,\<module\>:\<endmodule\>'

To use it, put the cursor on a begin or end while in command mode and press % -- it will jump to the matching end/begin. Press % again to jump back to where you started from.

You can put those commands in your ~/.vimrc (or ~/.gvimrc). Notice that the matchit package won't work if you're using vim in vi-compatible mode (with :set compatible).

More info is available with :h matchit, especially about how matchit interacts with the syntax mechanism.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.