tags:

views:

84

answers:

1

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?

+1  A: 

It is almost certainly a bug in vim and very likely a memory leak. I'm going to try to reproduce it out of curiosity, but I'd search or ask around in Vim-land for more focused information.

msw
@kyle: I cannot find the particular `python.vim` file your code snippet is from; URL me?
msw
It's something I made myself and is all that is in that file (note that it's not a syntax file). I pieced it together from various places (http://vim.wikia.com/wiki/Highlight_long_lines + the vimrc from the Python source iirc). But none of the other scripts I could find would remove the highlights when I opened another file type, so I don't use them.I didn't want to put it into a syntax file because afaik you can't colour things twice with it. Right now I have regular python syntax highlighting + these lines using matches + pyflakes using SpellBad.
Kyle MacFarlane