Vim拼写检查并非始终在.tex文件中工作.检查Vim中的区域 [英] Vim spellcheck not always working in .tex file. Check region in Vim

查看:97
本文介绍了Vim拼写检查并非始终在.tex文件中工作.检查Vim中的区域的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Vim编写我的.tex文件,但是我在Vim中的拼写检查器上遇到麻烦.有时它不检查单词,我认为可能是由于以下原因.

I use Vim to write my .tex files, but I am having trouble with the spell checker in Vim. Sometimes it does not check the words, and I think that it might be for the following reason.

由于显然Vim不应检查.tex文档中的所有单词,例如,不检查序言,因此它仅检查某些区域的拼写(在语法意义上).正如我从此处收集的那样,这些区域之一是texSectionZone.这些区域可能会变得很大,实际上通常是一个区域,因此Vim很难意识到它实际上位于texSectionZone区域(或其他区域)中,因此不检查拼写.如果我在文档中进行搜索,或者进行任何形式的跳过多行(或页面)的跳转,都可能会发生这种情况.

Since Vim is clearly not supposed to check all of the words in the .tex document, for example, not the preamble, it only check spelling in certain regions (in the syntax sense). As I have gathered from here, one of these regions is texSectionZone. These regions can become quite large, indeed a section often is, so Vim is having trouble realising that it actually is in a texSectionZone region (or in ay other), and therefore does not check the spelling. This can happen if I make a search in the document, or any kind of jump that skips multiple lines (or rather pages).

我得出的结论可能是以下原因:我知道命令

The way that I concluded this might be the reason is the following: I know that the command

:echo synIDattr(synID(line("."),col("."),1),"name")

在您的所在地区打印名称(我在此处找到了它)没用,我尝试了一下,它告诉我根本不在任何地区.它工作的地方,我在应该检查其拼写的区域.

prints the name of the region/regions you are in (I found it here), so when the spell checker did not work I tried this, and it told me that it was not in any region at all. The places it did work, I was in a region where it ought to check the spelling.

到目前为止,我唯一的解决方案是在我希望拼写检查的点上方找到最近的部分,然后将光标手动向下移回给定点.

So far my only solution is to find the nearest section above the point I want the speller to check, and then manually move the cursor back down to the given point.

理想情况下,我非常希望能确保不会发生这种情况的解决方案,但是我也想办法手动使vim更新"它所在的区域,而无需我经常移动光标.在后一种情况下,我正在考虑可以对快捷方式进行解决的方法.

Ideally I would very much like a solution that ensures that this does not happen, but I would also settle for a way to manually make vim 'update' which region it is in, without me having to move the cursor a lot. In the latter case I am thinking of a solution which could be made to a shortcut.

PS我对如何称呼这个问题感到怀疑.如果您想出一个更好地解释问题的标题,请随意进行更改.

PS I was in doubt about what to call the question. If you come up with a title which explain the problem better, fell free to change it.

推荐答案

syntax/tex.vim已经使用非常复杂的同步模式来确保语法突出显示准确,但是对于冗长而复杂的文档,可能仍然会失败.

syntax/tex.vim already uses quite elaborate sync patterns to ensure that the syntax highlighting is accurate, but for long and complex documents, this may still fail.

最好的办法是尝试同时增加两个值

Best you can do is trying to increase both values of

syn sync maxlines=200
syn sync minlines=50

(例如2000和500).将其放在~/.vim/after/syntax/tex.vim中以覆盖默认值.

(e.g. to 2000 and 500). Put this in ~/.vim/after/syntax/tex.vim to override the defaults.

syntax sync fromstart

可能会给出最佳结果,但可能会太慢.您可以在:help :syn-sync上找到语法同步的描述.

might give the best results, but may be too slow. You'll find a description of syntax syncing at :help :syn-sync.

这篇关于Vim拼写检查并非始终在.tex文件中工作.检查Vim中的区域的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆