Janmejay
Janmejay

Reputation: 1053

Color scheme in vim

I was trying to set 256 color for vim editor. I write C code using vim. In /usr/share/vim/vim72/colors directory I have many colourscheme script. When I tried to use any one of them using colourscheme command in .vimrc, it is working for all files with any extension. But when I am giving .pc extension to the file I am not getting the color scheme. I am getting the default color in the vim editor. Can any one help me on this?

Upvotes: 1

Views: 2688

Answers (2)

dimba
dimba

Reputation: 27571

This means that vi`m don't know file type of your file and thus can not pick up colour scheme. You can see the file type by typing:

:echo &ft

There're several ways to force file type. My preferred is a vim modline. This is a special line readed by line when the file is loaded. The line can containing misc settings regarding the file and one of them is file type:

#vim :ft=cpp

Initial character can be # or // ().ft stands for file type and can be any file type supported by your vim (in the example bvelow is cpp file type for C++ files).

On my system file type configuration files located in /usr/share/vim/vim72/ftplugin/

for more info write:

:help modeline

Additional way to force filetype for all *.pc files add the following file in your ~/.vimrc:

autocmd BufReadPre *.pc set filetype=cpp

Upvotes: 2

timmow
timmow

Reputation: 3625

You need to specify a filetype, assuming this is c code you are saving with a .pc extension. From vim, type the following

:set filetype=c

This will work if syntax highlighting is working for other files, without the .pc extension.

Upvotes: 3

Related Questions