GVim highlighting with matchadd eventually slows down?

Posted by Kyle MacFarlane on Stack Overflow See other posts from Stack Overflow or by Kyle MacFarlane
Published on 2010-04-03T23:09:12Z Indexed on 2010/04/03 23:13 UTC
Read the original article Hit count: 255

Filed under:
|
|

I have the following in ~/.vim/ftplugin/python.vim to highlight long lines, accidental tabs and extra whitespace in Python files:

hi CustomPythonErrors ctermbg=red ctermfg=white guibg=#592929
au BufWinEnter *.py call matchadd('CustomPythonErrors', '\%>80v.\+', -1)
au BufWinEnter *.py call matchadd('CustomPythonErrors', '/^\t\+/', -1)
au BufWinEnter *.py call matchadd('CustomPythonErrors', '\s\+$', -1)
au BufWinLeave *.py call clearmatches()

The BufWinLeave is so that the matches are cleared when I switch to another file in case that file isn't a .py file. It's an essential feature for me when working with something like Django.

It all works fine for random amounts of time; from ten minutes to hours (my guess is it depends on how many files I open/close). But eventually when any line over 80 characters is displayed GVim slows to a halt and requires a restart.

Does anyone have any ideas why this would eventually slow down?

© Stack Overflow or respective owner

Related posts about gvim

Related posts about vim