When I use sudo vim on a file it fails with:
$ sudo vim test
Error detected while processing /home/dcampbe1/.vimrc:
line 12:
E117: Unknown function: vundle#begin
line 13:
E492: Not an editor command: Plugin 'VundleVim/vundle.vim'
line 14:
E492: Not an editor command: Plugin 'bundle/vim-colors-solarized'
line 15:
E492: Not an editor command: Plugin 'tpope/vim-fugitive'
line 16:
E492: Not an editor command: Plugin 'w0ng/vim-hybrid'
line 17:
E492: Not an editor command: Plugin 'airblade/vim-gitgutter'
line 18:
E492: Not an editor command: Plugin 'vim-airline/vim-airline'
line 19:
E492: Not an editor command: Plugin 'vim-airline/vim-airline-themes'
line 20:
E492: Not an editor command: Plugin 'jreybert/vimagit'
line 21:
E492: Not an editor command: Plugin 'valloric/youcompleteme'
line 22:
E492: Not an editor command: Plugin 'scrooloose/nerdtree'
line 23:
E117: Unknown function: vundle#end
line 26:
E185: Cannot find color scheme 'hybrid'
line 149:
E471: Argument required
Press ENTER or type command to continue
However when I run vim on the same file it opens up correctly with my correct vundle config. I need to use sudo vim quite often due to many files being owned by root instead of by my user. I'm fine with the normal root config being used when run sudo vim, however I'm surprised that sudo vim tries to go into my vundle config and somehow fails.
Does anyone have an idea of what's going on? Either a fix where running sudo vim just goes to the normal root vim or goes to my own configured vim in .vimrc works.
/root
? 2. Recommended practice is to usesudoedit
(a.k.a.sudo -e
) instead of runningvim
as root.sudoedit
as suggested? Not only issudoedti
recommended oversudo vim
, it should avoid this problem you are having becausesudoedit
runs$EDITOR
as you instead of as root so your normal user configuration should work. – jw013 May 31 '18 at 15:31