4

I found when i use the command sudo vim /etc/www/main.wsgi the vim said:

neocomplcache disabled: "sudo vim" is detected and $HOME is set to your user's home. You may want to use the sudo.vim plugin, the "-H" option with "sudo" or set always_set_home in /etc/sudoers instead. Press ENTER or type command to continue

and when i ENTER and edit file, the neocomplcache seems goes wrong function.

the i search the google, I found the command vim sudo:/etc/www/main.wsgi but it seems doesn't use my own .vimrc configure file.

so, what you others to do ?

Liu Hao
  • 379
  • 1
  • 6
  • 15

1 Answers1

5

Add following mapping to your vimrc:

" Editing a protected file as 'sudo'
cmap W w !sudo tee % >/dev/null<CR>

Now edit the protected files as you normally do:

vim /etc/www/main.wsgi

but when you want to save the changes use :W instead of :w, vim will prompt for a sudo password, enter your sudo password and hit Enter. That's it!

Basharat Sialvi
  • 24,046
  • 8
  • 62
  • 82