VIM: “sudo vim bad_idea”

sudovim

An irc-user in #Vim urged me not to use Sudo with Vim like:

sudo vim bad_idea

When I am doing things in locations such as /var/www/, I cannot write without it. So not-using sudo becomes a problem. Of course, I could make changes in different locations such as /tmp/ and then copy dirs to /var/www. However, I sense an easier way.

  1. If you do not "sudo Vim", why?
  2. If yes to 1st question, how do you circumvent problems not to use sudo?

Best Answer

I fall under the first category: sudo vim /var/www/html/some_file is a bad idea; it allows shell escapes that aren't logged. Instead, use sudoedit /var/www/html/some_file; that has the same effect.