
當我在文件上使用 sudo vim 時,它失敗並顯示:
$ 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
但是,當我在同一個檔案上執行 vim 時,它會使用正確的 vundle 配置正確開啟。我需要經常使用 sudo vim,因為許多檔案由 root 而不是我的使用者擁有。我對運行 sudo vim 時使用的正常根配置沒問題,但是令我驚訝的是 sudo vim 嘗試進入我的 vundle 配置並以某種方式失敗。
有人知道發生了什麼事嗎?修正執行 sudo vim 僅轉到普通 root vim 或轉到 .vimrc 中我自己配置的 vim 的情況。