How to make the% key (go to the corresponding bracket) ignore the code with comments in Vim

1  #include <stdio.h>
2  int main(int argc, char* argv[]) {
3    int i=10;
4  /* } */
5    return 0;
6  }

If the cursor is in line 2 below {, and I press the key %, the cursor shows the corresponding closing bracket in line 4 (which is commented out), and not the corresponding closing bracket in line 6.

Is there any workaround for this?

+3
source share
1 answer

You need a plugin matchit. He extends the team in %various ways, including omitting comments. Included in Vim, but not enabled by default.

From it docs:

By default, words inside comments and lines are ignored if the cursor is not inside a comment or line when entering "%".

, .

+6

Source: https://habr.com/ru/post/1706313/


All Articles