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\>,' -- >From "know your smileys": %-) After staring at screen for 15 hours /// 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/202104111625.13BGPXuX499172%40masaka.moolenaar.net.
