Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

PlainBoringWhite for .txt

SomethingDarkBackdround for .c or .rb

share|improve this question

migrated from programmers.stackexchange.com Apr 13 '11 at 17:32

This question came from our site for professional programmers interested in conceptual questions about software development.

up vote 5 down vote accepted

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
share|improve this answer
    
This 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 Sep 3 '15 at 16:07

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.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .