Not sure what you meant by colors not used. Could you give details of
the your problem, or did you mean the difference between vim and gvim?
--
regards,
====================================================
GPG key 1024D/4434BAB3 2008-08-24
gpg --keyserver subkeys.pgp.net --recv-keys 4434BAB3
what worked for me is this: as root i changed directory to
/root -- there i created symbolic links to my ~/.vimrc,
~/.gvimrc, and ~/.vim path, where '~' means the home path of
my normal user
sc
I think that a better way is to setup environment:
# ~/.profile, ~/.bashrc, ~/.zshenv, etc.
EDITOR=vim
VISUAL=$EDITOR
export EDITOR VISUAL
and:
$ sudoedit file
for the first case, it should work, ubuntu by default will setup sudo to
use the user environment. but ubuntu by default do *not* have the
proper version of vim installed, you need to :sudo apt-get install vim
before you can use vim.
for the second case, you are using root environment, so you can do under
your user account:
sudo ln -s ~/.vim /root/.vim
sudo ln -s ~/.vimrc /root/.vimrc
then use your su and you can get the same vim env.
or
$ sudo -e file
sudoedit type 1 more key than sudo vi
sudo -e needs the same number of keystrokes, but sudo vi is easier to
remember.
So why do you think sudo -e or sudo edit is better than sudo vi ?
just a habit. actually sudo edit is easier to type than sudo -e
because the "-" is away from home position, that depends on keyboard
layout of course.
btw iirc nautilus allows mouse right click to call customised script
that bind to 'gsudo gvim file'.
The latter does not preserve your personal Vim environment.
See sudo(8):
-e The -e (edit) option indicates that, instead of running a command,
the user wishes to edit one or more files. In lieu of a command,
the string "sudoedit" is used when consulting the sudoers file. If
the user is authorized by sudoers the following steps are taken:
1. Temporary copies are made of the files to be edited with the
owner set to the invoking user.
2. The editor specified by the VISUAL or EDITOR environment vari‐
ables is run to edit the temporary files. If neither VISUAL
nor EDITOR are set, the program listed in the editor sudoers
variable is used.
3. If they have been modified, the temporary files are copied back
to their original location and the temporary versions are
removed.
If the specified file does not exist, it will be created. Note
that unlike most commands run by sudo, the editor is run with the
invoking user’s environment unmodified. If, for some reason, sudo
is unable to update a file with its edited version, the user will
receive a warning and the edited copy will remain in a temporary
file.
I setup my sudo to always preserve my personal environment for all
commands, so I do never need the sudo -e.
It's also horrifically dangerous to use "sudo vim" when "sudoedit"
would do. "sudo vim" means that vim runs as root, so a malicious
script, or a vim bug, could have catastrophic consequences.
"sudoedit" runs vim as your user, so malicious scripts or catastrophic
bugs can't result in an "rm -rf /" or worse being run.
If you don't absolutely *need* to run vim as root, I'd recommend
against it. And, if you *do* need to run vim as root, I'd recommend
disabling all plugins, colorschemes, syntax highlighting, etc. But
that's just my $0.02 - people less concerned with running an editor
with a history of exploitable bugs as root are of course welcome to do
so.
~Matt
It convince me.
So the difference is: sudo -e copies the file in tmp and edit as user,
while sudo vi edit the file as root.
Hope more user know it.