为什么“设置”语法不适用于 vim 中的语法高亮显示?

Laz*_*zer 3 vim vimrc

在搜索如何在 vim 中设置语法高亮时,我发现这个页面说 vimrc 应该有以下行

syntax on
Run Code Online (Sandbox Code Playgroud)

为什么不是这样的set syntax on就像我们有set nuset ai等等。

有了set syntax on,我得到这个错误

$ vi
  syntax=
Error detected while processing /home/lazer/.vimrc:
line   30:
E518: Unknown option: on
Hit ENTER or type command to continue
Run Code Online (Sandbox Code Playgroud)

set syntax,我明白了

$ vi
  syntax=
Hit ENTER or type command to continue
Run Code Online (Sandbox Code Playgroud)

jwe*_*ich 6

它应该是syntax onsyntax off

set syntax=something 用于更改当前语法(c、perl、nasm 等)。

更新:正如@garyjohn 在评论中指出的那样,可以使用set syntax=ONand为当前缓冲区及其相应的文件类型打开/关闭它set syntax=OFF