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?
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.
精彩评论