Vim Color Scheme for specific filetype

6

1

Is it possible to setup a specific colorscheme for a specific filetype in a vimrc file?

PlainBoringWhite for .txt

SomethingDarkBackdround for .c or .rb

geo

Posted 2011-04-13T17:30:38.003

Reputation: 73

Answers

6

As @Rein mentioned, you can use autocommand to achieve what you want. Add something like this to your .vimrc file:

"default colorscheme
colorscheme solarized

"different colorscheme for ruby and markdown
autocmd FileType ruby colorscheme railcasts
autocmd FileType markdown colorscheme mac_classic

ejel

Posted 2011-04-13T17:30:38.003

Reputation: 396

2This will cause vim to change the colorscheme for markdown and ruby but it will not return it to solarized when a different file type is opened (such as yaml for example) – Dorian – 2015-09-03T16:07:29.983

3

While you could use an aucommand to set a specific colorscheme for a specific filetype or filename pattern, it is more common to use a syntax file to define highlight groups for elements and then use your global colorscheme to handle coloring of those groups.

Rein Henrichs

Posted 2011-04-13T17:30:38.003

Reputation: 171