当我打开以.tex.
如果我有一个名为的文本文件foo.txt并在 vim 中打开它并执行:set spell,我会突出显示拼写错误的单词,我可以使用]s等移动到它们,并且我可以使用z=. 如果我重命名foo.txt为foo.tex并在 vim 中打开它,:set spell什么也不]s做,什么也不做,但是z=当光标在一个单词上时输入确实提供了更正选项。
当我foo.tex在 vim 中打开并执行 时:set filetype,我得到filetype=tex. 如果我改为执行:set filetype=latex、:set spell和]s等,则一切正常。
如何进行拼写检查以处理.tex文件类型文件?请注意,我只想在明确执行时进行拼写检查:set spell,我不希望默认情况下启用它。
该tex文件类型指定哪个语法地区应拼写检查,而不是让整个缓冲区是拼写检查。这样做是为了避免标记在实际上不应该进行拼写检查时被标记为拼写错误。
还有一些变量可以调整哪些区域进行拼写检查,如中所述:help ft-tex-syntax:
*g:tex_nospell*
Tex: No Spell Checking Wanted~
If you don't want spell checking anywhere in your LaTeX document, put >
let g:tex_nospell=1
into your .vimrc. If you merely wish to suppress spell checking inside
comments only, see |g:tex_comment_nospell|.
*tex-nospell* *g:tex_comment_nospell*
Tex: Don't Want Spell Checking In Comments? ~
Some folks like to include things like source code in comments and so would
prefer that spell checking be disabled in comments in LaTeX files. To do
this, put the following in your <.vimrc>: >
let g:tex_comment_nospell= 1
If you want to suppress spell checking everywhere inside your LaTeX document,
see |g:tex_nospell|.
*tex-verb* *g:tex_verbspell*
Tex: Want Spell Checking in Verbatim Zones?~
Often verbatim regions are used for things like source code; seldom does
one want source code spell-checked. However, for those of you who do
want your verbatim zones spell-checked, put the following in your <.vimrc>: >
let g:tex_verbspell= 1
Run Code Online (Sandbox Code Playgroud)
当您使用它的原因set filetype=latex是因为没有乳胶文件类型(除非您下载了一个)。tex 文件类型的所有语法规则都被清除,因此整个缓冲区都进行了拼写检查,这是在没有定义语法级别拼写检查时的默认设置。
如果您不希望拼写检查仅限于特定的语法区域,您可以将以下内容添加到 ~/.vim/after/syntax/tex.vim
syntax spell toplevel
Run Code Online (Sandbox Code Playgroud)