更改 vim 或 vi 解释文件的方式
所以我使用 vim (vi) 在命令行上进行编辑。每当我在以 .php、.pl、.cgi、.pm 等结尾的文件中进行编码时,它都会将其与它的语言相匹配,并进行正确的语法突出显示。但是,我正在编写一些 Perl 脚本,并且需要一些扩展名为“.lib”的单独文件。有没有办法让 vim 将其解释为 .pl 文件?现在它只是用红色突出显示所有内容,看起来很糟糕。
So I am using vim (vi) to edit on command line. Whenever I code in a file that ends in .php, .pl, .cgi, .pm, etc, it matches it up with what language it is and does the proper syntax highlighting. However, I am writing some perl scripts and I am requiring some separate files with the extension ".lib". Is there a way that I could have vim interpret this as a .pl file? right now it just highlights everything in red and looks pretty bad.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
:set filetype=pl
,如果你希望这种情况一直发生,请添加到你的 .vimrc
:set filetype=pl
, if you want this to happen all the time, addto your .vimrc
您可能正在寻找
autocmd
命令,它将根据文件名(或其他条件?)执行一些命令?尝试将类似的内容添加到您的
~/.vimrc
文件中:You're probably looking for the
autocmd
command, which will execute some commands based on filenames (or other criteria?)Try adding something like this to your
~/.vimrc
file: