Vim 无法自动识别 groff(联机帮助页)文件
我有:
$ vim --version
VIM - Vi IMproved 7.3 (2010 Aug 15, compiled Dec 1 2011 03:25:24)
使用 Debian 测试。
我正在摆弄我写的旧联机帮助页,注意到 vim (我最初使用 gedit 编写它,但已切换到 vim)在加载或使用 a 时无法将其识别为 nroff/groff 文件类型:
:filetype detect
它确实语法突出显示很好,当然,还有:
:set filetype=groff
还有其他人有这种行为吗?如果有的话找到解决办法吗?
顺便说一句,它可以正确识别 html、bash 和 python 脚本并设置正确的语法突出显示。只是似乎对不带 [FILENAME].1 类型后缀保存的 groff 文件犹豫不决。
谢里奥, 纳尼
I have:
$ vim --version
VIM - Vi IMproved 7.3 (2010 Aug 15, compiled Dec 1 2011 03:25:24)
using Debian testing.
I was playing around with an old manpage I wrote and noticed that vim (I used gedit to write it initially but have switched to vim) is not recognizing it as a nroff/groff filetype upon loading or with a:
:filetype detect
It does syntax highlighting fine, of course, with:
:set filetype=groff
Anyone else have this behaviour and if so find a fix?
BTW, it recognizes html, bash, and python scripts correctly and sets the correct syntax highlighting. Just seems to balk at groff files that are saved without the [FILENAME].1-type suffix.
Cheerio,
Narnie
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Vim 可以根据文件名和上下文来检测文件类型。看来在这种情况下 vim 只查看文件名。您可以编写自己的文件类型检测脚本来根据上下文找出这种类型的文件。 vim 的帮助中有一些关于如何执行此操作的基本说明。基本上你可以编写一个 vim 脚本来检测文件类型并将其放入
$VIMRUNTIME/scripts.vim
中。Vim can detect the filetype based on both the name of the file and the context. It appears that in this case vim only looks at the file name. You can write your own filetype detection script to figure out files of this type based on the context. The vim's help has some basic instructions on how to do this. Basically you can just write a vim script that detects the file type and put it in
$VIMRUNTIME/scripts.vim
.添加您的
~/.vimrc
文件:或者您用来定义 groff 文件的任何扩展名。
Add in your
~/.vimrc
file:Or whatever extension you're using to define your groff files.