How to interactively set syntax highlighting in VI editor
Asked Answered
V

4

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?

Verena answered 18/10, 2013 at 7:49 Comment(0)
T
9

Type following command after a colon:

:set ft=sql.
Timbale answered 28/6, 2016 at 10:24 Comment(0)
H
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.

Harp answered 13/1, 2015 at 9:48 Comment(0)
M
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

Mesic answered 13/2, 2016 at 1:15 Comment(0)
S
-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/

Stebbins answered 24/10, 2013 at 16:2 Comment(1)
No... no alias is present for viVerena

© 2022 - 2024 — McMap. All rights reserved.