3

On searching how to set syntax highlighting on in vim, I found this page which says that vimrc should have the following line

syntax on

Why is it not something like set syntax on? Like we have set nu, set ai etc.

With set syntax on, I get this error

$ vi
  syntax=
Error detected while processing /home/lazer/.vimrc:
line   30:
E518: Unknown option: on
Hit ENTER or type command to continue

and with set syntax, I get this

$ vi
  syntax=
Hit ENTER or type command to continue

1 Answer 1

6

It should be syntax on or syntax off.

set syntax=something is used to change the current syntax (c, perl, nasm, etc).

UPDATE: As @garyjohn pointed in comments, it's possible to turn it on/off for the current buffer and its corresponding filetype using set syntax=ON and set syntax=OFF.

2
  • You can also use set syntax=OFF to turn off syntax highlighting for the current buffer and set syntax=ON to enable syntax highlighting for the current buffer according to the current filetype.
    – garyjohn
    Oct 18, 2010 at 15:20
  • @garyjohn: ohh, thanks! Updated accordingly.
    – jweyrich
    Oct 18, 2010 at 20:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.