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

Solution 1:

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.

Solution 2:

I usually have use the same .vimrc and .vim folders as my main users and link them to a safe backupped place on Dropbox - wich btw is awesome for this kind of task.

The location of the home folder for your su is /var/root. Therefore .vimrc and the .vim folder belong there.