gvim 长多行字符串突出显示
我在 python 源代码中广泛使用多行文档字符串来包含文档测试。不幸的是,vim/gvim 似乎在语法突出显示方面遇到了困难,有时会丢失它的位置并忘记它位于字符串文字的中间,并且突出显示从字符串“翻转”到源,从源到字符串。
我可以向上滚动到顶部并再次向下滚动,vim 通常可以解决问题,但有时需要尝试几次。
除了让我的文档字符串更短之外,有没有办法帮助 vim 按顺序突出显示这些长文字?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
:syntax syn
控制 Vim 如何同步应用于文本中特定点的语法状态 (:help syn-sync
)。为了获得最准确的同步(但这会减慢 vim 的速度),请尝试:或者,如果您想在发现错误时手动同步,请尝试此命令(您可以将其映射到键盘快捷键):
您可能还会发现
minlines 很有用。来自
:help syn-sync
因此,将其放入您的 .vimrc 中可能会帮助您:
编辑:找到此页面,其中包含您需要的一切:
http://vim.wikia.com/wiki/Fix_syntax_highlighting
:syntax syn
controls 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
minlines
useful. From:help syn-sync
So 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
您可能不希望从头开始同步您正在编辑的所有类型的代码,而只是 html。如果是这种情况,请将其添加到您的 vimrc 中:
You probably don't want sync fromstart for all types of code you are editing, just html. If that's the case, add this to your vimrc: