[vim/vim] matchit: match_words in ftplugin/tex.vim (#1052)

18 views
Skip to first unread message

Konfekt

unread,
Sep 9, 2016, 11:40:21 AM9/9/16
to vim/vim

How about replacing

if exists("loaded_matchit")
  let b:match_words .= ',\\begin\s*\({\a\+\*\=}\):\\end\s*\1'
endif " exists("loaded_matchit")

by

if exists("loaded_matchit")
  setlocal matchpairs-=<:>
  let b:match_words = &l:matchpairs .
      \ ',' . '\%(^\|[ (]\)\@<=\$\$\?' . ':' . '\$\?\$\%($\|[ ).\,;\:?!\-]\)' .
      \ ',' . '\%(^\s*\)\@<=\\begin{\w\+\*\?}' . ':' . '\%(^\s*\)\@<=\\end{\w\+\*\?}'

For example, the regex

\\begin\s*\({\a\+\*\=}\):\\end\s*\1

does not allow for indented environments such as

  \begin{itemize}
    ...
  \end{itemize}

Regarding the matching of opening and closing $ ... $, this will never
be possible by a mere regex, but the above regex is a pragmatic
work-around that works if certain natural conventions are followed.

This mail was sent to Benji Fisher, the maintainer of the $VIMRUNTIME/ftplugin/tex.vim file the March 2, but yet no response.


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub

dkearns

unread,
Mar 25, 2026, 1:51:57 AM (yesterday) Mar 25
to vim/vim, Subscribed
dkearns left a comment (vim/vim#1052)

@Konfekt, are you willing to vouch for your younger self?


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/1052/4123980545@github.com>

Enno

unread,
Mar 25, 2026, 3:28:56 AM (yesterday) Mar 25
to vim/vim, Subscribed
Konfekt left a comment (vim/vim#1052)

I've relatively recently updated this on Stack Exchange to read

let b:match_words = get(b:, 'match_words', &l:matchpairs) .
      \ ',' . '\%(^\|[ (/]\)\zs\\(' . ':' . '\\)\ze\%($\|[ )/.\,;\:?!\-]\)' .
      \ ',' . '\%(^\|[ (/]\)\zs\\\[' . ':' . '\\\]\ze\%($\|[ )/.\,;\:?!\-]\)' .
      \ ',' . '\%(^\|[ (/]\)\zs\$[^$ ]' . ':' . '[^$ ]\zs\$\ze\%($\|[ )/.\,;\:?!\-]\)' .
      \ ',' . '\%(^\|[ (/]\)\zs\$\$' . ':' . '\$\$\ze\%($\|[ )/.\,;\:?!\-]\)' .
      \ ',' . '^\s*\zs\\begin{\([^} \t]\+\)}' . ':' . '\%(^\s*\)\zs\\end{\1}'

and it has been working well for all my purposes. Here's a supposedly more reliable full-fledged plugin even older than this thread. I didn't yet receive a reply by @benjifisher though. I vouch for its inclusion into ftplugin/tex.vim. Thank you for reviving this @dkearns


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/1052/4124361792@github.com>

Reply all
Reply to author
Forward
0 new messages