I make extensive use of multiline docstrings in my python source code to include doctests. Unfortunately, vim/gvim seems to have a hard time with syntax highlighting, occasionally losing it’s place and forgetting that it’s in the middle of a string literal, and the highlighting “flips” from string to source and source to string.
I can scroll up to the top and back down again, and vim usually fixes the problem, but sometimes it takes a few tries.
Aside from making my docstrings shorter, Is there a way to help vim keep the highlighting on these long literals in order?
:syntax syncontrols how Vim synchronizes the syntax state that should apply at a particular point in the text (:help syn-sync). For the most accurate sync (but this will slow vim down), try:Or if you want to sync manually whenever you notice it’s wrong, try this command (you could map it to a keyboard shortcut):
You might also find
minlinesuseful. From:help syn-syncSo putting this in your .vimrc might help you:
Edit: found this page which has everything you need:
http://vim.wikia.com/wiki/Fix_syntax_highlighting