I switch between Ruby and C++ frequently. My trick, which I admit is complete unplanned fluke, is different IDEs. Sublime for Ruby and XCode for C++. They look so different that my brain just disregards the other language. I briefly tried Ruby in XCode and nothing made any sense.
Assuming you don't want to install multiple editors, perhaps different colour schemes might produce something similar in your brain.