これらの2つのvim autocmdはなぜ互いに重なり合うのですか?

これらの2つのvim autocmdはなぜ互いに重なり合うのですか?

.vimrcには2つのautocmd設定があります。

autocmd FileType python highlight OverLength ctermbg=red ctermfg=white guibg=red
autocmd FileType python match OverLength /\%80v.\+/
autocmd FileType python highlight ExtraWhitespace ctermbg=blue guibg=blue
autocmd FileType python match ExtraWhitespace /\s\+$/

1 つ目は、80 文字を超える行の部分を赤の背景として表示します。
一方、2番目は行の末尾に青色で余分なスペースを表示します。

問題は、彼らが一緒に働かないということです!
両方を有効にすると、2番目のものだけがExtraWhitespace機能します。しかし、コメントを
付けると正常に動作します。ExtraWhitespaceOverLength

なぜこれが起こり、どのように解決するのですか?

ベストアンサー1

:2match2番目の項目の場合(プラグインの詳細:help :2matchと注意事項を参照)::3matchmatchparen

autocmd FileType python highlight OverLength ctermbg=red ctermfg=white guibg=red
autocmd FileType python match OverLength /\%80v.\+/
autocmd FileType python highlight ExtraWhitespace ctermbg=blue guibg=blue
autocmd FileType python 2match ExtraWhitespace /\s\+$/

おすすめ記事