24

Using vi, I want to display files in distinguished colors in unix. If I save a file as .sql or .java it will highlight the keywords. I want to make changes to which words are highlighted, and in what color.

How do I control syntax highlighting and color schemes with various vi file extensions?

Chris Stryczynski
  • 30,145
  • 48
  • 175
  • 286
Toshi
  • 243
  • 1
  • 3
  • 7

4 Answers4

9

Type following command after a colon:

:set ft=sql.
Karol Król
  • 3,320
  • 1
  • 34
  • 37
4

I just did it by putting :syntax on. I suppose you want to save the settings so it can be highlighted each time you open one of those files, in which case the answer by Eric it's the correct one.

facundofarias
  • 2,973
  • 28
  • 27
1

For file specific settings, there is also the power of modelines.

You can put them in the first or last five (unless you change modelines variable) lines to control variable settings.

eg:

# vim: syn=sh

or even:

/* vim: tw=60 ts=2: */

see vim's help: :h modeline

ErichBSchulz
  • 15,047
  • 5
  • 57
  • 61
-2

Are you sure one of the user don't have an alias to vim or something like that? CF: http://masstransmit.com/garage_blog/alias-vi-vim/

Schminitz
  • 314
  • 1
  • 2
  • 13