Vim 拼写检查并不总是在 .tex 文件中工作.在 Vim 中检查区域 [英] Vim spellcheck not always working in .tex file. Check region in Vim

查看:23
本文介绍了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天全站免登陆