.Vimrc configuration file does not load when editing with 'sudo'

I have a problem with a .vimrc file, the problem is that it sometimes loads, and sometimes not.

  1 set number
  2 syntax on
  3 set autoindent
  4 map <F2> :!g++ % -Wall -time -O<CR>
  5 echo "it works!"

I added echo to check if it is loaded, and when I type, for example. vim .vimrc, it loads and shows that “it works” in the terminal, but when I type, for example. sudo vim test.cppit does not load, the message does not appear. I am using debian.

+4
source share
3 answers

sudo, Vim (root). , ~/.vimrc ( , ). :

  • .vimrc: sudo vim -u $HOME/.vimrc ( ).
  • sudo -e <file> sudoedit.
  • .vimrc ( .vim ) root: sudo ln -s $HOME/.vimrc .vimrc; sudo ln -s $HOME/.vim .vim
  • root , ( , - !)
+14

sudo vim vim root. , vim vimrc , .

, ,

sudo -e <file>

vim .

sudo -e sudoedit tmp , . , sudo vim .

+2

vim AM2 Amazon AMI AWS.

, sudo. , , :

.profile, .bashrc .. :

EDITOR=vim
VISUAL=$EDITOR
export EDITOR VISUAL

, sudoedit /path/to/file.

0

All Articles