On So, 11 Apr 2021, Bram Moolenaar wrote:
> > Doug Kearns wrote: > > > On Sun, 11 Apr 2021 at 22:53, Bram Moolenaar <[email protected]> wrote: > > > 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. > > > > Using a lookbehind works here. > > > > E.g., > > \ '\<if\>:\<el\%[seif]\>:\%(\%(^\||\)\s*\)\@<=\<en\%[dif]\>,' . > > > > You might be able to come up with a more general solution by extending > > the match_skip test. > > Indeed, that appears to work. A look-behind can be a bit expensive, but > in this case it's probably not that bad. > > So try this in runtime/ftplugin/vim.vim: > > let b:match_words = > \ > '\<\%(fu\%[nction]\|def\)!\=\s\+\S\+(:\%(\%(^\||\)\s*\)\@<=\<retu\%[rn]\>:\%(\%(^\||\)\s*\)\@<=\<\%(endf\%[unction]\|enddef\)\>,' > . > \ > '\<\(wh\%[ile]\|for\)\>:\%(\%(^\||\)\s*\)\@<=\<brea\%[k]\>:\%(\%(^\||\)\s*\)\@<=\<con\%[tinue]\>:\%(\%(^\||\)\s*\)\@<=\<end\(w\%[hile]\|fo\%[r]\)\>,' > . > \ > '\<if\>:\%(\%(^\||\)\s*\)\@<=\<el\%[seif]\>:\%(\%(^\||\)\s*\)\@<=\<en\%[dif]\>,' > . > \ '{:},' . > \ > '\<try\>:\%(\%(^\||\)\s*\)\@<=\<cat\%[ch]\>:\%(\%(^\||\)\s*\)\@<=\<fina\%[lly]\>:\%(\%(^\||\)\s*\)\@<=\<endt\%[ry]\>,' > . > \ '\<aug\%[roup]\s\+\%(END\>\)\@!\S:\<aug\%[roup]\s\+END\>,' If we separate out the `:lang` into its own syntax group, we could easily simply adjust b:match_skip variable to skip the :lang part. Currently, the :language statement is detected as vimCommand, as is e.g. a single endif statement, so we can't easily skip it from matchit. In that case using the about regex might work better. Best, Christian -- Der Elfenbeinturm ist heute überfüllt mit Aktivisten. Sie sitzen dort aktiv. -- Ludwig Marcuse (Argumente und Rezepte) -- -- 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/20210411170136.GB2222154%40256bit.org.
