Tony wrote:

> My vimrc includes the following snippet:
> 
> if has('unix')
>   language messages C
> else
>   language messages en
> endif
> 
> I just noticed that repeatedly hitting % (with matchit enabled) cycles
> from the if to the else to the en in "language messages en" and back.
> % on the final endif goes to the next outer if clause, which happens
> to be an "if 1" near the top of my vimrc correlated with an endif near
> the bottom, in order to avoid syntax errors for assignment statements
> etc. in builds compiled without the +eval feature.
> 
> b:match_words is set (in that buffer) to
> \<\%(fu\%[nction]\|def\)!\=\s\+\S\+(:\<retu\%[rn]\>:\<\%(endf\%[unction]\|enddef\)\>,\<\(wh\%[ile]\|for\)\>:\<brea\%[k]\>:\<con\%[tinue]\>:\<end\(w\%[hile]\|fo\%[r]\)\>,\<if\>:\<el\%[seif]\>:\<en\%[dif]\>,{:},\<try\>:\<cat\%[ch]\>:\<fina\%[lly]\>:\<endt\%[ry]\>,\<aug\%[roup]\s\+\%(END\>\)\@!\S:\<aug\%[roup]\s\+END\>,
> 
> This means that "en" will be interpreted as "endif" even if, like
> here, it is part of a longer statement. I'm not sure how to fix it
> considering that if, else, elseif, endif should be recognised not only
> at start of line but also after a vertical bar, in both cases with
> zero or more intervening spaces and/or tabs.

It is possible to only match "endif" at the start of the line or after a
bar:

        '\<if\>:\%(^\||\)\s*el\%[seif]\>:\%(^\||\)\s*en\%[dif]\>,'

But then the cursor will move to the start of the line or the bar.
Putting in \zs to position the cursor doesn't work, because the plugin
uses \zs itself.

This requires someone digging into the bowels of the plugin to figure
out a solution.  This is all regexp stuff.

-- 
>From "know your smileys":
 :-X    My lips are sealed

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///                                                                      \\\
\\\        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/202104111253.13BCrcoa453929%40masaka.moolenaar.net.

Raspunde prin e-mail lui