この記事はVim Advent Calendar 2012 : ATND 79日目の記事になります。 78日目は@raa0121のLingrのBot「VimAdv」を作ったでした。 今回は、Vimの意外と知られていない正規表現\%を紹介したいと思います。 任意にマッチするアトム列 \%[] Vimの各コマンドは省略名をもっているので、これは必須の正規表現かなっと思います。 echo matchstr("fun", 'fu\%[nction]') " 'fun' " `\%[]`を使わないとこう書かなければいけない!! echo matchstr("fun", 'fu\(n\(c\(t\(i\(o\(n\?\)\?\)\?\)\?\)\?\)\?\)\?') " 'fun' 部分正規表現としてカウントされないグループ化 \%(\) これはmatchlist()には結構必須で、matchlis