Auto change keyboard layout based on application focus

I basically use US keyboard for programming and Spanish for everything else, and I´m always switching keyboard layout when I change from browser to VIM or console.

In Linux (gnome), keyboard layout was a per application preference, that the window manager remembered automatically, so for every application, if you switched keyboard layout, when you focus back to that application the keyboard layout would change for you.

Is there any way of doing this in OSX Lion?


Solution 1:

If you go to System Preferences -> Language & Text -> Input Sources, you should have the option to "Allow a different one for each document" under Input source options.

The change is per document and not per application, but unless you change the setting for one document when you have several open you might not even notice the difference.