I don't know a single setting or package to do what you want. It's not provided by viper itself.
That said, you can write some advice which does the job. The key being that you need to advise all the ways you switch buffers/windows. For example, if you switch windows through the other-window
command (C-x o), you'll want this:
(defadvice other-window (around other-window-maintain-viper-state activate
activate)
"when switching windows, pull the viper-current-state along"
(let ((old-window-state viper-current-state))
ad-do-it
(viper-change-state old-window-state)))
But, switching windows using the mouse doesn't go through that function, and to get that to work you need to advise select-window
in exactly the same way:
(defadvice select-window (around select-window-maintain-viper-state activate
activate)
"when switching windows, pull the viper-current-state along"
(let ((old-window-state viper-current-state))
ad-do-it
(viper-change-state old-window-state)))
If you find you use another mechanism to switch windows/buffers that doesn't use the above, it just takes a tiny bit of digging (M-x describe-key ) to find out what new thing you should be advising.