[vim/vim] vim's '%' command should ignore comments (Issue #20329)

4 views
Skip to first unread message

rendcrx

unread,
6:16 AM (16 hours ago) 6:16 AM
to vim/vim, Subscribed
rendcrx created an issue (vim/vim#20329)

Steps to reproduce

int main()
{
	// {
}
  1. vim --clean a.c
  2. move cursor to '{' of line 2
  3. %

Expected behaviour

Vim should ignore characters inside comments and jump to the matching '}' of the next line.

I can't use % in ‘vim/src/cindent.c:2136‘ to jump, pressing % does nothing. I guess the reason is Vim doesn't ignore the '{' of line 2690.

Version of Vim

VIM - Vi IMproved 9.2 (2026 Feb 14, compiled May 13 2026 21:13:30) Included patches: 1-357

Environment

N/A

Logs and stack traces


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications on the go with GitHub Mobile for iOS or Android.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/20329@github.com>

Christian Brabandt

unread,
6:58 AM (15 hours ago) 6:58 AM
to vim/vim, Subscribed
chrisbra left a comment (vim/vim#20329)

Vims % matching is simplistic and does not consider comments. User the matchit plugin for more advanced % matching. Closing as duplicate


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications on the go with GitHub Mobile for iOS or Android.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/20329/4533709300@github.com>

Christian Brabandt

unread,
6:58 AM (15 hours ago) 6:58 AM
to vim/vim, Subscribed

Closed #20329 as completed.


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications on the go with GitHub Mobile for iOS or Android.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issue/20329/issue_event/25923208484@github.com>

rendcrx

unread,
11:28 AM (11 hours ago) 11:28 AM
to vim/vim, Subscribed
rendcrx left a comment (vim/vim#20329)
fun! s:HighlightOperators()
  syntax match alabaster_Special1 "?\|+\|-\|\*\|:\|<\|>\|&\||\|!\|\~\|\^\|%\|)\|(\|\.\|/\(/\|*\)\@!"
  syntax match alabaster_Special2 "\[\|\]\|{\|}\|,\|;"
  syntax match alabaster_Assign "=\|+=\|-=\|\*=\|\/=\|%=\|&&=\|||=\|\~=\|\^=\|&=\||=\|:="
  syntax match alabaster_CompOverride "==\|!=\|>=\|<=\|<=>"
  syntax match alabaster_FatArrowOverride "=>"
  syntax match alabaster_Glue "::"

  hi alabaster_Special1 ctermfg=37 guifg=#009999
  hi alabaster_Special2 ctermfg=34 guifg=#009900
  hi alabaster_Assign ctermfg=83 guifg=#66FF33
  hi alabaster_CompOverride ctermfg=37 guifg=#009999
  hi alabaster_FatArrowOverride ctermfg=34 guifg=#009900
  hi alabaster_Glue ctermfg=243 guifg=#999999 ctermbg=black guibg=#000000 cterm=bold

endfunction

augroup Alabaster
  au Syntax * call s:HighlightOperators()
  au ColorScheme * call s:HighlightOperators()
augroup END

packadd matchit

Thank you. But my theme has syntax match, it seems conflict with matchit. Do you know how to deal? I try to use matchadd to instead syntax match, but it will lead to highlight characters inside comments.


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications on the go with GitHub Mobile for iOS or Android.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/20329/4535373637@github.com>

Christian Brabandt

unread,
12:38 PM (10 hours ago) 12:38 PM
to vim/vim, Subscribed
chrisbra left a comment (vim/vim#20329)

And the question is what?


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications on the go with GitHub Mobile for iOS or Android.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/20329/4535750890@github.com>

rendcrx

unread,
8:39 PM (2 hours ago) 8:39 PM
to vim/vim, Subscribed
rendcrx left a comment (vim/vim#20329)

After using the vimscript above, matchit also fails to bracket-match in the aforementioned C files.


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications on the go with GitHub Mobile for iOS or Android.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/20329/4538506847@github.com>

Reply all
Reply to author
Forward
0 new messages