MacOS – Where to put the .vimrc file for sudo in OS X Lion

macosterminaltext-editorvi

I always put a .vimrc in my home folder for turning :syntax on. But in OS X Lion it seems that sudo vi foo.txt ignore or can't find this vim configuration anymore.

Has anyone experiences the same thing?

Best Answer

Try doing sudo visudo and making sure that this lines appears somewhere in there:

Defaults  env_keep += "HOME"

This should maintain the HOME directory and ~ should would as it did in Snow Leopard.