Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
747 views
in Technique[技术] by (71.8m points)

latex - Vim spellcheck not always working in .tex file. Check region in 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.

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.

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 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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Spell checking is not done where no syntax group are defined (or found by vim). I find it useful to enable spell checking even for the undefined group (see toplevel in vim's syntax documentation).

To do so, write the command:

syntax spell toplevel

in the file ~/.vim/after/syntax/tex.vim. Make the file if it does not exist.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...