3

I have a problem that when I open SAS programs (.sas files) in Vim, the colors look very ugly (a mix of white and black background, etc.).

Example here: This is how vim looks when I open a SAS file (setf=sas)

This is how vim looks when I open a SAS file (setf=sas)

My colorscheme is koehler.

I have tried changing colorscheme, but then this happens:

When I run :colo delek, vim looks like this. Syntax highlighting seems to have disappeared.

So I run :setf sas, and syntax highlighting appears again with correct colors.

So I run :setf sas, and syntax highlighting appears again with correct colors.

I am not sure what the underlying problem is here: It could be a problem in the colorscheme 'koehler', however, since syntax highlighting just disappears when I change colorscheme, it might rather be a problem in filytype detection.

How do I fix this?

Can I somehow configure vim to use a different colorscheme for a specific filetype? (e.g. use delek for .sas files?)

Update 2015-05-15: Appearently, the problem only occurs in gvim and not Vim run in a terminal. I have a screenshot here of how it looks when I open a .sas file in Vim from a terminal: https://i.sstatic.net/AALq4.jpg

Update 2016-01-15:

Problem was fixed by editing sas.vim and changing all the constant color definitions to HiLinks:

HiLink sComment Comment
HiLink sCard    String
HiLink sDate_Time   Special
HiLink sKeyword Structure
HiLink sFmtInfmt    Special
HiLink sString  String
HiLink sText    String
HiLink sNumber  Number
HiLink sProc    Structure
HiLink sSection Structure
HiLink mDefine  Define
HiLink mKeyword Structure
HiLink mReference   Structure
HiLink mSection Structure
HiLink mText    String
Thomas
  • 455

1 Answers1

3

Explaining this behaviour

Syntax highlighting is meant to modify a colour scheme. The default SAS syntax highlighting is meant to modify a normal colour scheme, like I use, and then it is suitable to show data as blue on white. On a reverse video scheme, like koehler, it is not.

When you change your colour scheme to a normal one, vim throws away your syntax highlighting, because it might well be incompatible with the newly selected colour scheme.

You can solve this

by creating a custom syntax highlighting for SAS in reverse video. To do this, edit your sas.vim file (on my windows system in C:\Program Files (x84)\vim74\syntax), setting all guibg to Black, replacint guifg=Blue guifg=LightBlue and applying similar changes till it looks alright