Upgraded vim, no colors for root

Issues related to software problems.
gohanman
Posts: 11
Joined: 2009/11/20 17:50:16

Upgraded vim, no colors for root

Postby gohanman » 2009/11/23 15:37:17

I upgraded vim on Friday with yum and noticed today that if I edit a file as root, I no longer get any syntax highlighting. I find this a little baffling because:

~/.vimrc doesn't exist for my regular user
/root/.vimrc also doesn't exist
/etc/vimrc has all my settings, including filetype and syntax hightlighting

Typing :syntax on or :syntax off as root produces no errors and has no effect. My first thought was that some environment variable doesn't get set when running as root via sudo, so I tried actually logging in as root and there's still no color.

Any ideas what else I can check?

Inside vim version is 7.0.237. Long --version output is:

Code: Select all

VIM - Vi IMproved 7.0 (2006 May 7, compiled Sep 19 2009 17:23:40)
Included patches: 1, 3-4, 7-9, 11, 13-17, 19-26, 29-31, 34-44, 47, 50-56, 58-64, 66-73, 75, 77-92, 94-107, 109, 202, 234-237
Modified by <bugzilla@redhat.com>
Compiled by <bugzilla@redhat.com>
Huge version without GUI.  Features included (+) or not (-):
+arabic +autocmd -balloon_eval -browse ++builtin_terms +byte_offset +cindent
-clientserver -clipboard +cmdline_compl +cmdline_hist +cmdline_info +comments
+cryptv +cscope +cursorshape +dialog_con +diff +digraphs -dnd -ebcdic
+emacs_tags +eval +ex_extra +extra_search +farsi +file_in_path +find_in_path
+folding -footer +fork() +gettext -hangul_input +iconv +insert_expand +jumplist
 +keymap +langmap +libcall +linebreak +lispindent +listcmds +localmap +menu
+mksession +modify_fname +mouse -mouseshape +mouse_dec +mouse_gpm
-mouse_jsbterm +mouse_netterm +mouse_xterm +multi_byte +multi_lang -mzscheme
-netbeans_intg -osfiletype +path_extra +perl +postscript +printer +profile
+python +quickfix +reltime +rightleft -ruby +scrollbind +signs +smartindent
-sniff +statusline -sun_workshop +syntax +tag_binary +tag_old_static
-tag_any_white -tcl +terminfo +termresponse +textobjects +title -toolbar
+user_commands +vertsplit +virtualedit +visual +visualextra +viminfo +vreplace
+wildignore +wildmenu +windows +writebackup -X11 -xfontset -xim -xsmp
-xterm_clipboard -xterm_save
   system vimrc file: "/etc/vimrc"
     user vimrc file: "$HOME/.vimrc"
      user exrc file: "$HOME/.exrc"
  fall-back for $VIM: "/usr/share/vim"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H     -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions
-fstack-protector --param=ssp-buffer-size=4 -m32 -march=i386 -mtune=generic -fasynchronous-unwind-tables
-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_FORTIFY_SOURCE=2    -D_REENTRANT -D_GNU_SOURCE 
-Wdeclaration-after-statement -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/include/gdbm 
-I/usr/lib/perl5/5.8.8/i386-linux-thread-multi/CORE  -I/usr/include/python2.4 -pthread   
Linking: gcc   -Wl,-E -Wl,-rpath,/usr/lib/perl5/5.8.8/i386-linux-thread-multi/CORE   -L/usr/local/lib -o vim       
-lncurses  -lselinux  -lacl -lgpm   -Wl,-E -Wl,-rpath,/usr/lib/perl5/5.8.8/i386-linux-thread-multi/CORE  -L/usr/local/lib
/usr/lib/perl5/5.8.8/i386-linux-thread-multi/auto/DynaLoader/DynaLoader.a -L/usr/lib/perl5/5.8.8/i386-linux-thread-multi/CORE
-lperl -lresolv -lutil -lc -L/usr/lib/python2.4/config -lpython2.4 -lutil -lm -Xlinker -export-dynamic   

User avatar
AlanBartlett
Forum Moderator
Posts: 9311
Joined: 2007/10/22 11:30:09
Location: ~/Earth/UK/England/Suffolk
Contact:

Upgraded vim, no colors for root

Postby AlanBartlett » 2009/11/23 17:22:44

What happens if you explicitly use /usr/bin/vim?

Code: Select all

$ locate bin/vim bin/vi
/bin/vi
/bin/view
/usr/bin/vim
/usr/bin/vimdiff
/usr/bin/vimtutor
[i]<snip>[/i]
$

Also, what does an alias command return? (For root and for an ordinary user.)

gohanman
Posts: 11
Joined: 2009/11/20 17:50:16

Re: Upgraded vim, no colors for root

Postby gohanman » 2009/11/23 20:35:20

AlanBartlett wrote:
Also, what does an alias command return? (For root and for an ordinary user.)


That would be it. Normal user has alias vi="vim", root does not. Thanks.

User avatar
AlanBartlett
Forum Moderator
Posts: 9311
Joined: 2007/10/22 11:30:09
Location: ~/Earth/UK/England/Suffolk
Contact:

Re: Upgraded vim, no colors for root

Postby AlanBartlett » 2009/11/24 16:16:58

That would be it. Normal user has alias vi="vim", root does not. Thanks.

You're welcome. :-)

Speeddymon
Posts: 4
Joined: 2012/06/28 03:02:59

Re: Upgraded vim, no colors for root

Postby Speeddymon » 2016/06/12 22:06:35

Sorry to post on such an old thread.

I thought I would update that this is still a "problem" in CentOS 7.

The simplest workaround (and, my personal opinion, the "proper" workaround) is to edit /etc/profile.d/vim.sh as follows:

Code: Select all

[root@fileserver profile.d]# diff -u vim.sh{,.new}
--- vim.sh      2016-06-12 17:05:48.646214170 -0500
+++ vim.sh.new  2016-06-12 17:00:07.258203245 -0500
@@ -1,7 +1,7 @@
 if [ -n "$BASH_VERSION" -o -n "$KSH_VERSION" -o -n "$ZSH_VERSION" ]; then
   [ -x /usr/bin/id ] || return
   ID=`/usr/bin/id -u`
-  [ -n "$ID" -a "$ID" -le 200 ] && return
+  [ -n "$ID" -a "$ID" -le 200 -a "$ID" -ne 0 ] && return
   # for bash and zsh, only if no alias is already set
   alias vi >/dev/null 2>&1 || alias vi=vim
 fi

forumitu
Posts: 108
Joined: 2014/02/20 14:30:51

Re: Upgraded vim, no colors for root

Postby forumitu » 2016/06/14 09:55:17

You may want to open an issue at https://bugzilla.redhat.com/, that way the problem will probably be fixed for everybody in a future release.